Download MetaTrader 5

ObjectGetValueByShift suggestion

To add comments, please log in or register
skatt
186
skatt  
Since the function ObjectGetValueByShift returns a different value for each time frame, it would be nice if we could specify which time frame we want to get the value from.
ZenTrader
52
ZenTrader  
It took me several hours to figure out that one, and the reason why my code was not working. Is there an alternative?
whroeder1
14786
whroeder1  
skatt: Since the function ObjectGetValueByShift returns a different value for each time frame, it would be nice if we could specify which time frame we want to get the value from.

It doesn't return a different value for each time frame. You are asking for the values at different times. iTime(NULL,PERIOD_D1,x) != iTime(NULL,PERIOD_M1,x) so of course you get different values from ByShift(x) from different timeframes.

If you want the value from another timeframe, get the proper shift

datetime  BOD = iTime(NULL, PERIOD_D1, 0);
int      iBOD = iBarShift(NULL,0, BOD);
double   valueAtBOD = ObjectGetValueByShift(name, iBOD);

To add comments, please log in or register