Download MetaTrader 5

Indicator : crossing (bar & previous bar) (URGENT)

To add comments, please log in or register
Launch your trading signal. Make profit from paid subscription!
Icham Aidibe
10044
Icham Aidibe 2014.08.14 13:34 

Hi there,

Need help with a simple crossing code in an indicator : 

 if ((close[bar - 1] < Pivot[0]) && (close[bar] > Pivot[0])) { BuyBuffer[bar]=low[bar]-Range*SignalShift; }
 if ((close[bar - 1] > Pivot[0]) && (close[bar] < Pivot[0])) { SellBuffer[bar]=high[bar]+Range*SignalShift; }

Error (not during compilation, but when attached to chart) :

array out of range in (363,12)
MrGrey
8747
MrGrey 2014.08.14 14:30  

Array out of range points to column 12 so I guess content of bar = 0 and bar - 1 = -1 but -1 is not a valid index. 

MrGrey
8747
MrGrey 2014.08.14 14:33  
Maybe the formula should be "close[bar+1]" depending on the rest of your program logic?
Icham Aidibe
10044
Icham Aidibe 2014.08.14 15:23  
MrGrey:
Maybe the formula should be "close[bar+1]" depending on the rest of your program logic?
Here it is :p
To add comments, please log in or register