Ref function not working properly in amibroker

I am trying on a code which contains ref function. But when I take ref function as -1 it count it as 5 candles and give scan result after 5 candles. Even when I divide it by 5 it wont work properly. I tried in 3 diff version of amibroker. Kindly help


a =StochD( periods = 14, Ksmooth=3, Dsmooth=3 ) ;
b= StochK( periods = 14, ksmooth=3 );
D1 =Cross(Ref(r,s),-1)  ;
d11= D1 AND (b>a);
Buy = d11;
Buy = TimeFrameExpand(d11,in5Minute);
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Notify.wav", "Audio alert", 2 );

This code will give scan result on next candle where macd cross occur if stochastic is +ve. Check this code is right or wrong . If wrong plz correct it. And if right kindly give me example where u r using ref -1 functions.

the above syntax is correct and no errors

1 Like