Good day to you all. I have a gap strategy (short only) using fixed stop loss and n-bar stop loss. When I try to set the fixed stop loss as 3-percent from the entry price, I observe that it does not close the position at (Entry price * 1.03) exactly but at some other prices, e.g. close price / prices I could not explain.
I have tried my very best to go through AFL Function Reference - APPLYSTOP and also post by ApplyStop query but I am still not be able to figure out the solution to this problem. Can anyone point me where I might have done wrong please?
SetPositionSize(100,spsPercentOfEquity);
SetTradeDelays( 0, 0, 0, 0 );
SetOption( "ActivateStopsImmediately", False );
SetOption( "AllowSameBarExit", False);
SetOption("MaxOpenPositions",100);
GapD = GapDown();
MovingAv1 = MA(C,Optimize("M1",30,10,100,10));
MovingAv2 = MA(C,Optimize("M2",100,50,250,50));
Short = GapD AND MovingAv1 < MovingAv2;
Cover = 0;
ApplyStop( stopTypeNBar, stopModeBars,Optimize("Time Stop",21,1,40,2),1);
//ApplyStop( stopTypeTrailing, stopModePercent, Optimize("TS",5,3,10,1) ,1);
ApplyStop(stopTypeLoss, stopModePercent, Optimize("Stop Loss",3,3,10,1),1);
Equity(1,-1);
Filter = 1;
AddColumn(ValueWhen(Short,Close)*1.03,"ValueWhen",1.2);
AddColumn(H,"H",1.2);
AddColumn(Short,"Short",1.2);
AddColumn(Cover,"Cover",1.2);
AddColumn(C,"Close",1.2);
AddColumn(ShortPrice,"ShortPrice",1.2);