Thanks for the reply TrendSurfer. Yes, It was stopped out a few days later. Happy to post the code but it is quite long
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "Close", IIf(Close > Open, colorblue,colorRed), styleBar);
//Initialise functions
Account_Equity = 100000;
SetOption("InitialEquity", Account_Equity);
//SetOption("MaxOpenPositions", Max_Open_Positions);
SetPositionSize(100, spsPercentOfEquity);
SetOption("AccountMargin", 10);
//55 day high & low, 20 day high & low for trade signals
Upper=55;
Lower=20;
Highest_55_Days = HHV(Ref(H,0),Upper);
Lowest_55_Days = LLV(Ref(L,0),Upper);
Highest_20_Days = HHV(Ref(H,0),Lower);
Lowest_20_Days = LLV(Ref(L,0),Lower);
//Trend filters
MA1=EMA(C,50);
MA2=EMA(C,100);
//Stop
Stoplength = ATR(20) ;
RiskPerShare = 2 * Stoplength;
ApplyStop( stopTypeLoss, stopModePoint, RiskPerShare, True );
//Trade Signals
Buy = Cross(High, Ref( Highest_55_Days, -1 )) AND MA1 >= MA2;
Sell = Cross(Ref( Lowest_20_Days, -1 ), Low);
Short = Cross(Ref( Lowest_55_Days, -1), Low) AND MA2 >= MA1;
Cover = Cross(High, Ref(Highest_20_Days, -1)); //OR MA1 >= MA2;
//Stop Excessive signals
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell, Buy);
Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short);
//Plot Stopline
//Determine entry points
Entry = Buy OR Short;
EntryPriceBuy = ValueWhen(Entry, BuyPrice);
EntryPriceShort = ValueWhen(Entry, SellPrice);
AtrAtEntry = ValueWhen(Entry, RiskPerShare);
//Now plot the stoplines
inTrade = Flip(Buy,Sell);
inTrade2 = Flip(Short,Cover);
Stopline=IIf(intrade, Max(EntryPriceBuy - AtrAtEntry, Lowest_20_Days), Null);
Stopline2=IIf(intrade2, Min(EntryPriceShort + AtrAtEntry, Highest_20_Days), Null);
Plot(Stopline,"Stop Loss",colorRed,styleLine,0,0,0,0);
Plot(Stopline2,"Stop Loss",colorRed,styleLine,0,0,0,0);
//Plotting entry and exit prices
bi=BarIndex();
fvb=FirstVisibleValue(bi);
lvb=LastVisibleValue(bi);
SellorCoverTrigger = "Stop,Stop,Profit,Trail,N-Bars,Ruin";
for(i=fvb; i<=lvb; i++)
{
if(Buy[i])
PlotText("Buy\n" + BuyPrice[i],i, BuyPrice[i], colorGreen,-1,-40);
if(Sell[i])
PlotText(StrExtract(sellorcovertrigger, Sell[i]-1) +"\n" + SellPrice[i], i, SellPrice[i], colorRed, -1,-30);
if(Short[i])
PlotText("Short\n" + ShortPrice[i], i, ShortPrice[i], colorRed, -1,0);
if(Cover[i])
PlotText(StrExtract(sellorcovertrigger, Cover[i]-1)+ "\n" + CoverPrice[i], i, CoverPrice[i], colorRed, -1, 0);
}
//Plot buy and sell shapes
buysignalshape = sellsignalshape = shortsignalshape = 0;
PlotShapes( buy*shapeUpArrow, colorGreen, 0, Low);
PlotShapes( sell*shapeSmallCircle, colorRed, 0, SellPrice);
PlotShapes( short*shapeDownArrow, colorRed, 0, High);
PlotShapes( cover*shapeSmallCircle, colorGreen, 0, CoverPrice );