Checking for recently closed bars on multiple timeframes - page 2

 

this code loops from M1 to H4 on one tick you still need to add the comparing logic.

what do you mean no movement? 1 minute is one minute it's not determined by ticks it will only stop when market closes.

you mean no movemt = no new ticks ?

if you want to run it on time use OnTimer() in stead of ontick but then it never stops counting unless deinit.

 
Marco vd Heijden:

this code loops from M1 to H4 on one tick you still need to add the comparing logic.

what do you mean no movement? 1 minute is one minute it's not determined by ticks it will only stop when market closes.

if you want to run it on time use OnTimer() in stead of ontick but then it never stops counting unless deinit.

Thanks very much for all your help Marco. I need to spend a little time reading up on switches, etc. I think this can be a much more efficient solution than what I have.

 

Mark 

 

well you don't have to use switch the if statements are equally usable.

You can just compare iTime[x] with iTime[X-1]

datetime M1;datetime M5;datetime M15;datetime M30;datetime H1;datetime H4;datetime D1;    
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- load current values
M1=iTime(Symbol(),PERIOD_M1,0);M5=iTime(Symbol(),PERIOD_M5,0);M15=iTime(Symbol(),PERIOD_M15,0);M30=iTime(Symbol(),PERIOD_M30,0);
H1=iTime(Symbol(),PERIOD_H1,0);H4=iTime(Symbol(),PERIOD_H4,0);D1=iTime(Symbol(),PERIOD_D1,0);
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+   



//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- check if values have changed

   if(M1!=iTime(Symbol(),PERIOD_M1,0))
    { 
    // New bar for M1
    // Do something..
    M1=iTime(Symbol(),PERIOD_M1,0);// set new value
    }
    
   if(M5!=iTime(Symbol(),PERIOD_M5,0))
    { 
    // New bar for M5
    // Do something..
    M5=iTime(Symbol(),PERIOD_M5,0);// set new value
    } 
    
   if(M15!=iTime(Symbol(),PERIOD_M15,0))
    { 
    // New bar for M15
    // Do something..
    M15=iTime(Symbol(),PERIOD_M15,0);// set new value 
    }
    
   if(M30!=iTime(Symbol(),PERIOD_M30,0))
    { 
    // New bar for M30
    // Do something..
    M30=iTime(Symbol(),PERIOD_M30,0);// set new value
    } 
    
   if(H1!=iTime(Symbol(),PERIOD_H1,0))
    { 
    // New bar for H1
    // Do something..
    H1=iTime(Symbol(),PERIOD_H1,0);// set new value
    }
    
   if(H4!=iTime(Symbol(),PERIOD_H4,0))
    { 
    // New bar for H4
    // Do something..
    H4=iTime(Symbol(),PERIOD_H4,0);// set new value
    }
    
   if(D1!=iTime(Symbol(),PERIOD_D1,0))
    { 
    // New bar for D1
    // Do something..
    D1=iTime(Symbol(),PERIOD_D1,0);// set new value
    }
  }
//+------------------------------------------------------------------+
 
Hi, I wonder if anyone can help me with a question. I am trading using mean renko bar charts and was looking for an expert adviser that would enter the market once 2 renko bars of the same colour / direction were formed. It would then exit once a bar of the opposite direction / colour was formed. Can anyone advise where I might be able to find such an indicator or does it exist ?

Sincerely,
James H
 

so renko only draws a bar after X pips in the same direction.

i guess it would be similar to opening after X amount of pips in one direction.

say for example your renko bar is set at ten pips then, in your case you would open an order after 20 pips up or down is that correct?

and then close the order after a bar of ten pips in opposite direction.

im sure something like that exists i have also seen Heiken Ashi experts that open after two red or white candles.

 
Marco vd Heijden:

so renko only draws a bar after X pips in the same direction.

i guess it would be similar to opening after X amount of pips in one direction.

say for example your renko bar is set at ten pips then, in your case you would open an order after 20 pips up or down is that correct?

and then close the order after a bar of ten pips in opposite direction.

im sure something like that exists i have also seen Heiken Ashi experts that open after two red or white candles.

This is correct with the renko candle, it will only form once it has moved your predifined number of pips. Perhaps I will look into some of the heiken ashi ea's to see if they are adaptable.
 

james1972:
This is correct with the renko candle, it will only form once it has moved your predifined number of pips. Perhaps I will look into some of the heiken ashi ea's to see if they are adaptable.I suppose the difficulty is trying to find who has created this. Thanks very much for your response.

james 

 

And thank you Marco for you help, once again, on my topic of checking recently closed bars.

 

Mark 

 
One more thing Marco - do you know why I receive the warning in my original posted program  'declaration of 'TF' hides global declaration at line 41'?
 
yes it can bring problems if you declare a variable twice so declare it on top above oninit() and the message should disappear .
Reason: