israelhernando: could you help me with this? I need for every candle in OnCalculate event, to know the high and low of yesterday, relative to this candle. I'm getting the yesterday hi/lo for all candles, but not the yesterday hi/lo of the specific candle. I don't find the way to do it
Please note that the following code is untested and it does not check if the shift/index is valid and if within the Bars indexing range. You will have to add the necessary code to check for that.
int dayIndex = iBarShift( _Symbol, PERIOD_D1, time[ i ] ); double highestY = iHigh( _Symbol, PERIOD_D1, dayIndex + 1 ), lowestY = iLow( _Symbol, PERIOD_D1, dayIndex + 1 );
great, sometimes it does rare things, but it works fine
I'll revise
thank you
I fixed this, by getting the weekday, and finding the correct day
int dayIndex = iBarShift( _Symbol, PERIOD_D1, time[i], true); MqlDateTime stm; TimeToStruct(time[i],stm); int dif; if (stm.day_of_week == 1) dif = 3; else if (stm.day_of_week == 7) dif = 2; else dif = 1; double highestY = iHigh(_Symbol, PERIOD_D1, dayIndex + dif), lowestY = iLow(_Symbol, PERIOD_D1, dayIndex + dif);
I don't know if this is the best way, but it seems work.
Thanks

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
HI,
could you help me with this? I need for every candle in OnCalculate event, to know the high and low of yesterday, relative to this candle.
If I use this
I'm getting the yesterday hi/lo for all candles, but not the yesterday hi/lo of the specific candle
I don't find the way to do it
Thank you