what do you have
for(i=0; i<=Bars_To_Plot*(Lead_Tf/Special_Candle_Tf); i++) { Lead_Tf_Candle_i = iBarShift(Symbol(),Lead_Tf,Time[i],false); Lead_Tf_Candle_t = iTime(Symbol(),Lead_Tf,Lead_Tf_Candle_i); Special_Candle_i = iBarShift(Symbol(),Special_Candle_Tf,Lead_Tf_Candle_t,false)-Special_Candle_Index; ObjectDelete(); if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]>Open[Special_Candle_i]) { CreateObjectR(); } else if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]<=Open[Special_Candle_i]) { CreateObjectR(); } }
Lead_Tf_Candle_i = iBarShift(Symbol(),Lead_Tf,Time[i],false); Lead_Tf_Candle_t = iBarShift(Symbol(),Lead_Tf,Time[Lead_Tf_Candle_i],false); // Lead_Tf_Candle_t = iTime(Symbol(),Lead_Tf,Lead_Tf_Candle_i); Special_Candle_i = iBarShift(Symbol(),Special_Candle_Tf,Lead_Tf_Candle_t,false)-Special_Candle_Index;
Nope, I am looking for Special_Candle_i on the lower Tf.
In order to get the iBarShift(), I need the specific Candle time, not index.
For example, I want to see the first M1 candle of every M15 (this works fine from my code).
When I want to see the first H4 candle of every W1, I need to subtract 1 from the index.
When I want to see the first D1 of MN1 or W1, it stops working properly.
And, there are other issues like avoiding weekend candles, and the fact that different instruments can open at different time.
So, I am looking for an universal solution to get the index of the n candle of any lower timeframe from any other
higher timeframe candle.
Specific candle time is
datetime time=iTime(_Symbol,PERIOD_D1,candle);
Specific candle time is
I am not looking for the obvious.
for(i=0; i<=Bars_To_Plot*(Lead_Tf/Special_Candle_Tf); i++) { // This is supposed to get the higher Tf index according to the lower Tf time. Lead_Tf_Candle_i = iBarShift(Symbol(),Lead_Tf,Time[i],false); // This is supposed to get the higher Tf time according to the above index. Lead_Tf_Candle_t = iTime(Symbol(),Lead_Tf,Lead_Tf_Candle_i); // This should, then get the index of the specified lower Tf candle of a specified // higher Tf candle, and it does, but when applied to D1, W1, MN1 it doesn't work properly, // it plots some, but not all. Special_Candle_i = iBarShift(Symbol(),Special_Candle_Tf,Lead_Tf_Candle_t,false)-Special_Candle_Index; ObjectDelete(); if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]>Open[Special_Candle_i]) { CreateObjectR(); } else if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]<=Open[Special_Candle_i]) { CreateObjectR(); } }

- www.mql5.com
I don't want a job, I need a friendly programmers help.
You look at for example M15 bars.
Then you want the first one ?
That will be the one that trips over along with the first H1 bar.
So you filter for that.
datetime _M15=iTime(_Symbol,PERIOD_M15,0); datetime _H1=iTime(_Symbol,PERIOD_H1,0);
if(_M15!=iTime(_Symbol,PERIOD_M15,0)) { if(_H1!=iTime(_Symbol,PERIOD_H1,0)) { Print("Here is the first M15 bar"); _H1=iTime(_Symbol,PERIOD_H1,0); } _M15=iTime(_Symbol,PERIOD_M15,0); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody!
I need help with the code snippet to find the first candle (or any next candle) of a lower timeframe for any other higher timeframe candle. Problems arrise from H4 and higher. I want to write myself an indicator to extract the OHLC data from that specific lower Tf candle and plot something according to that data.
All help appreciated.