Hi,

I do backtesting, and want to check MA at the time of buying.

My code looks like 

buyrule = cross(MACD, signal);
buy = buyrule;
buyprice = close;
sellrule = cross(signal, MACD);
sell = sellrule;
sellprice = close;
if (buyrule = true) {
 str = StrFormat("%0.2f", MA(Close,6));
 _TRACE(NumToStr( DateTime(), formatDateTime ) + ", " + str);

}

I always get the MA at the ending time of last bar instead. 

Thanks for any help!

Charles


Reply via email to