help required for amibroker

#1
hello all,
i am trying to build a dummy system where i buy when ma crosses over price and sell when the price is below the low of the bar before buy bar(
Code:
 ref(l,-barssince(buy==1)-1)
here is what i have until now:
Code:
Buy = ( C> EMA( C, Lema ) ) AND C> Ref( H, -1 );
Buybarssince=BarsSince(Buy==1);
Sell = Ref(L,-BarsSince(Buy)-1)>C;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
BuyPrice=O;
PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);
Plot(Ref(L,-BarsSince(Buy)-1),"LOW",colorBlack);
PlotShapes((Ref(L,-BarsSince(Buy)-1)>C)*shapeHollowSquare,colorBlack,0,High);
Plot(C,"Close",colorRed);

if you plot the above chart as an indicator you will see that the hollow squares are where the sell(red down arrows ) should be but they are not. I dont know what mistake is being done. please help me out.
 

Similar threads