Hello to All,
I have a modified version of a Parabolic Entry/Exit system that I found on this forum.
My Problem is that I am trying to backtest this and the backtest doenst show the correct entry/exit prices.
This is just on forex data and I am sure that my problem lies with me not understanding how to construct the proper syntax to get the trade to reverse at the psar value.
Can someone take a look and point me in the right direction?
It is not reversing a trade when it hits a 50 pip drawdown.
Thanks for your Time
EK
I have a modified version of a Parabolic Entry/Exit system that I found on this forum.
My Problem is that I am trying to backtest this and the backtest doenst show the correct entry/exit prices.
This is just on forex data and I am sure that my problem lies with me not understanding how to construct the proper syntax to get the trade to reverse at the psar value.
Can someone take a look and point me in the right direction?
PHP Code:
/*********************************************************
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
**********************************************************/
var vPSAR = null;
var vLastAlert = -1;
var MyPSar = null;
var EntryPrice = null;
var Msg = "";
function preMain() {
setPriceStudy(true);
setStudyTitle("ParabolicSAR");
setCursorLabelName("PSAR");
setDefaultBarFgColor(Color.blue);
setDefaultBarThickness(2);
setPlotType(PLOTTYPE_DOT);
//checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicParabolic.efs");
var fp1 = new FunctionParameter("Start", FunctionParameter.NUMBER);
fp1.setLowerLimit(0);
fp1.setDefault(0.02); //Edit this value to set a new default
var fp2 = new FunctionParameter("Increment", FunctionParameter.NUMBER);
fp2.setLowerLimit(0);
fp2.setDefault(0.018); //Edit this value to set a new default
var fp3 = new FunctionParameter("Max", FunctionParameter.NUMBER);
fp3.setLowerLimit(0);
fp3.setDefault(0.5); //Edit this value to set a new default
}
function main(Start, Increment, Max) {
if (vPSAR == null) vPSAR = new ParabolicStudy(Start, Increment, Max);
/****************************************************
Insert your code following this text block
Use vPSAR.getValue(ParabolicStudy.STOP) for your code
*****************************************************/
MyPSar = vPSAR.getValue(ParabolicStudy.STOP,-1);
if ( MyPSar >= high(-1) && Strategy.isShort()== false)
{
Msg = "Short"
goShort(1);
}
if (MyPSar <= low(-1) && Strategy.isLong() == false)
{
Msg = "Long"
goLong(1);
}
if ( Strategy.isLong() )
{
if ( close() < EntryPrice - .0050 )
{
Msg = "Rv2Short";
goShort(2);
}
}
if ( Strategy.isShort() )
{
if ( close() > EntryPrice + .0050 )
{
Msg = "Rv2Long";
goLong(2);
}
}
return vPSAR.getValue(ParabolicStudy.STOP);
}
function goLong(Type)
{
EntryPrice = MyPSar;
if ( Type == 1 )
{
Strategy.doLong(Msg, Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, EntryPrice);
}
else
{
Strategy.doLong(Msg, Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, EntryPrice + .0050);
}
if(vLastAlert!=2)drawTextRelative(0, low(-1), "B", Color.green, Color.yellow, Text.FRAME | Text.ONTOP| Text.CENTER | Text.BOLD, null, 12);
vLastAlert=2;
}
function goShort(Type)
{
EntryPrice = MyPSar;
if ( Type == 1 )
{
Strategy.doShort(Msg , Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, EntryPrice);
}
else
{
Strategy.doShort(Msg , Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, EntryPrice - .0050);
}
if(vLastAlert!=1)drawTextRelative(0, high(-1), "S", Color.red, Color.yellow, Text.FRAME | Text.ONTOP | Text.CENTER | Text.BOTTOM | Text.BOLD, null, 12);
vLastAlert=1;
}
Thanks for your Time
EK
Comment