Download MetaTrader 5
To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
Lorentzos Roussos
7068
Lorentzos Roussos 2014.11.03 17:43 

Hello Mql.

I am developing an indicator on MQL4 , what i am doing is utilizing a while loop -blocking further operations- (placed in OnInit function) until

all the bars have loaded from the broker in a chart.

I Check if the current time - last candle time is <= one bar time for this period.

heres the segment that ... makes MT4 freeze . :)

Enlighten if you can . :)


   //check bars loaded state
      datetime time_now=TimeCurrent();
      int minute_now=time_now;   
      int minute_need=Period()*60;
   while(Bars_Loaded==0)
    {
      int minute_last_bar=Time[0];
      if(minute_now-minute_last_bar<=minute_need)
      {
      Bars_Loaded=1;
      }   
      Alert("State :"+Bars_Loaded);
      Sleep(1000);     
    } 



 

Laszlo Tormasi
2385
Laszlo Tormasi 2014.11.03 18:37  
LoRio:

Hello Mql.

I am developing an indicator on MQL4 , what i am doing is utilizing a while loop -blocking further operations- (placed in OnInit function) until

all the bars have loaded from the broker in a chart.

I Check if the current time - last candle time is <= one bar time for this period.

heres the segment that ... makes MT4 freeze . :)

Enlighten if you can . :)




 

You have answered your own question: it is blocking further operations.

http://docs.mql4.com/runtime/running

"All indicators share the resources of graphic interface thread of the terminal"

When you change the timeframe then the indicator blocks the terminal so it can not load the candles. If it can not load the candles, Bars_Loaded will be always 0...

Lorentzos Roussos
7068
Lorentzos Roussos 2014.11.03 18:40  
lost89:

You have answered your own question: it is blocking further operations.

http://docs.mql4.com/runtime/running

"All indicators share the resources of graphic interface thread of the terminal"

When you change the timeframe then the indicator blocks the terminal so it can not load the candles. If it can not load the candles, Bars_Loaded will be always 0...

I see my error . Thank you .
I'll transform this to monitor if the candles have loaded through OnTimer and act accordingly
/
To add comments, please log in or register