SetTradeDelays(0,0,1,1);
SetOption ("allowsamebarexit",false);
SetOption("initialequity",10000);
SetOption("MaxOpenPositions",1);
SetPositionSize(100/1,spsPercentOfEquity);
BuyPrice = Close;
SellPrice = Close;
ps1=Optimize("ps1",0.95,0.90,0.95,.01);
Cond1 = C<Ref(C,-1) AND Ref(C,-1)<Ref(C,-2) AND Ref(C,-2)<Ref(C,-3) AND Ref(C,-3)<Ref(C,-4) AND Ref(C,-4)<Ref(C,-5) AND DayOfWeek()==5;
Cond2 = C/Ref(C,-5)<=ps1 AND DayOfWeek()==5;
// BUY & SELL RULES
Buy = Cond1 OR Cond2;
Sell = C<0;
bars = Optimize("bars",1,1,20,1); // exit after 10 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );