Hey guys.
This simple strategy buys when there are three consecutive higher closes and shorts when there are three consecutive lower closes.
Normally, it is a reversal system which covers long at a short signal and cover shorts vice versa.
So I decided to trail it with SAR on zorro but it doesnt seem to work because it still obeys the reversal system
The code needs something to prevent either longs or shorts when a position is open unless the SAR has stopped the position out.
Here is the code:
function run()
{
StartDate = 2002 ;
EndDate = 2021;
BarPeriod = 1440;
MaxLong = 1;
MaxShort = 1;
LookBack = 200;
vars Close = series(priceClose());
Stop = 2*ATR(100);
Trail = SAR(0.02,0.02,0.2);
if ( (Close[2]>Close[3]) and (Close[1]>Close[2]) and (Close[0]>Close[1]) )
enterLong();
if ( (Close[2]<Close[3]) and (Close[1]<Close[2]) and (Close[0]<Close[1]) )
enterShort();
set(PLOTNOW);
plot("SAR",SAR(0.02,0.02,0.2),DOT,BLUE);
}
Kindly give me the cheat code....