Ontimer freezes MT5

 

I have been facing some issues on testing OnTimer but it does not happen always

only sometimes so hard to record the event, Timer stops and I also use time compare like if current bar timelocal is not syncing fast to last 2 bars time then alert ,so i may know when OnTimer function freezes and i can check error using GetLastError

 but it never gives alerts just everything freezes and until the EA is restarted it does not work.

Do anyone has solution for this?

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Arpit T:

I have been facing some issues on testing OnTimer but it does not happen always

only sometimes so hard to record the event, Timer stops and I also use time compare like if current bar timelocal is not syncing fast to last 2 bars time then alert ,so i may know when OnTimer function freezes and i can check error using GetLastError

 but it never gives alerts just everything freezes and until the EA is restarted it does not work.

Do anyone has solution for this?

First guess would be an infinite loop somewhere . Second , a deletion of an object that does not exist , or , an editing of an object that does not exist.

I have always been "gating" ontimer execution but i dont know if that achieves anything .

 

Yes I use while loop to update bars on custom symbol

while(!IsStopped()) {
      MyFunction();
      }

but I want to get notified if this loop stops, In MyFunction I already added conditions to nofify if bar stops updating but it all freezes

           
             Comment((long)TimeGMT()," :Gmt, Bar Time:  ", (long)result[0].time);
            if((long)TimeGMT() == (long)result[0].time-PeriodSeconds(PERIOD_M1) )
            Alert("Network stopped ", GetLastError());

but alert never comes and bars are stopped updating

 
Arpit T #:

Yes I use while loop to update bars on custom symbol

but I want to get notified if this loop stops, In MyFunction I already added conditions to nofify if bar stops updating but it all freezes

but alert never comes and bars are stopped updating

Are you cycling through the "component" symbol's ticks in the loop ?

hold up you call this while loop on every timer ? do you kill the timer ?

I have never used IsStopped() why are you checking against it ?
 

Are you cycling through the "component" symbol's ticks in the loop ?

Yes i am updating candle data and it works when there is while loop

hold up you call this while loop on every timer ? do you kill the timer ?

I have never used IsStopped() why are you checking against it ?

I kill the timer on deinit 

as on ducumentation i read, its advised 

Documentation on MQL5: Language Basics / Operators / Loop Operator while
Documentation on MQL5: Language Basics / Operators / Loop Operator while
  • www.mql5.com
Loop Operator while - Operators - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Arpit T #:

Yes i am updating candle data and it works when there is while loop

I kill the timer on deinit 

as on ducumentation i read, its advised 

I think you can safely call MyFunction() without the while .

If i'm not mistaken , you are telling the terminal keep running this until you can't or something.

 
Lorentzos Roussos #:

I think you can safely call MyFunction() without the while .

If i'm not mistaken , you are telling the terminal keep running this until you can't or something.

socket connection without while loop does not work, i tried it.

 
Arpit T #:

socket connection without while loop does not work, i tried it.

doesn't the data stay at the port until you pull it ? Its udp ? 

I've had a local (same network) socket connection operate like that . 

Call once in timer and check

 
Lorentzos Roussos #:

doesn't the data stay at the port until you pull it ? Its udp ? 

I've had a local (same network) socket connection operate like that . 

Call once in timer and check

no its wss data. in OnTImer i checked many times nothing is updated