Find first candle of any highr timeframe. - page 2

 
Marco vd Heijden:

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.

Your solution is very basic.
I don't want to check for every possible case seperately.
I want a universal solution for all cases possible.

But, I guess I will need to do some checkinig for some cases.

 
Because you have to check them both to see if they both tripped over.
 
Marco vd Heijden:
Because you have to check them both to see if they both tripped over.

Good hint, I did some checking, thanks.

 
If it can help anybody:

for(i=0; i<=Bars_To_Plot*(Lead_Tf/Special_Candle_Tf); i++)
{ 
    // Get the index of the higher Tf candle:
    Lead_Tf_Candle_i = iBarShift(Symbol(),Lead_Tf,Time[i],false);
    // Get the time of the higher Tf candle:
    Lead_Tf_Candle_t = iTime(Symbol(),Lead_Tf,Lead_Tf_Candle_i);
    // Get the index of the lower Tf candle:
    Special_Candle_i = iBarShift(Symbol(),Special_Candle_Tf,Lead_Tf_Candle_t,false)-Special_Candle_Index;
    // Get the time of the lower Tf candle:
    Special_Candle_t = iTime(Symbol(),Special_Candle_Tf,Special_Candle_i);
    // Check if the time of the lower Tf candle is right with the higher Tf candle:
    if(Special_Candle_t<Lead_Tf_Candle_t)
     {
    // Adjust the lower Tf index:
    Special_Candle_i = iBarShift(Symbol(),Special_Candle_Tf,Lead_Tf_Candle_t,false)-Special_Candle_Index-1;
     }
    if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]>Open[Special_Candle_i])
     {
     DoSomething();
     }
    else
    if(Period()==Special_Candle_Tf&&Close[Special_Candle_i]<=Open[Special_Candle_i])
     {
     DoSomething();
     }
}