is RefreshRates enough to be used on a EA to know if Symbol is updating or not?

 

Good Day...

I would like to ask if RefreshRates will be enough to be used on an EA if a certain symbol is updating or not and it will give an alert if it is not for more than 5 minutes... Or there any functions that is precise to know whether a certain symbol is updating or not.

Thank you very much...

 

Read: https://book.mql4.com// and learn how MQL works.

The EA will run the Start function every tick. If it's a simple EA (no artificial ticks), it will use the newest information, but it will not update if there are no new ticks. A currency will only 'update' when there is new price information, and a new tick is sent.. so the EA start function will only run in that situation.

As far as I have found so far... there's no simple way to make MT4 do anything in the case of no ticks being sent. The only solution I can think of is to use a single Start function iteration with loops to create artificial ticks.

As for using RefreshRates... it's only useful if price is changing faster than your program can work, so it has no use if there are no ticks sent for 5 minutes.

 
alladir:

Read: https://book.mql4.com// and learn how MQL works.

The EA will run the Start function every tick. If it's a simple EA (no artificial ticks), it will use the newest information, but it will not update if there are no new ticks. A currency will only 'update' when there is new price information, and a new tick is sent.. so the EA start function will only run in that situation.

As far as I have found so far... there's no simple way to make MT4 do anything in the case of no ticks being sent. The only solution I can think of is to use a single Start function iteration with loops to create artificial ticks.

As for using RefreshRates... it's only useful if price is changing faster than your program can work, so it has no use if there are no ticks sent for 5 minutes.


I have created a simple EA which i use the MarketInfo(Symbol(),MODE_TIME) to get the last Market Time then i compare it with the CurrentTime(). If the time between the two exceeds 5 minutes or more then the symbol is not updating for more than 5 minutes...
 

It can't work because the Start function only runs when a new tick is received. So generally, MODE_TIME will always equal TimeCurrent().

If the price doesn't change for 5 minutes, i.e., your EA doesn't receive a new tick for 5 minutes, it won't run the code.

Why do you need your EA to give this warning? Is there another way to do it?

 
alladir:

It can't work because the Start function only runs when a new tick is received. So generally, MODE_TIME will always equal TimeCurrent().

If the price doesn't change for 5 minutes, i.e., your EA doesn't receive a new tick for 5 minutes, it won't run the code.

Why do you need your EA to give this warning? Is there another way to do it?


i have created this so that i can easily monitor on what symbols are not updating because it is hard to monitor all the symbols from time to time. The logic is that it will send and alert via email whenever one of the symbols is not updating. The only problem is that as what you have said EA's are dependent on the new tick available which means it will be only active when new ticks are present. In this case, if any symbols is not updating for 5 minutes, the EA itself will not be working...
 
alladir:

It can't work because the Start function only runs when a new tick is received. So generally, MODE_TIME will always equal TimeCurrent().

If the price doesn't change for 5 minutes, i.e., your EA doesn't receive a new tick for 5 minutes, it won't run the code.

Why do you need your EA to give this warning? Is there another way to do it?

Only if the symbol in the MarketInfo() call is the chart symbol . . .
 
RaptorUK:
Only if the symbol in the MarketInfo() call is the chart symbol . . .


Can you give any idea on how to monitor if a certain symbol is not updating. I mean accurately... because the EA is a no go then i shifted to scripts with this formula which will identify if the result is greater or equal to 5 minutes...

      symbolTime=TimeHour(iTime(Symbol(),PERIOD_M1,0))*60+TimeMinute(iTime(Symbol(),PERIOD_M1,0));
      serverTime=TimeHour(TimeCurrent())*60+TimeMinute(TimeCurrent());
      
      if(serverTime-symbolTime>=5)
      {
         alert=serverTime-symbolTime;
         Alert("Symbol "+Symbol()+" is not updating for 5 minutes or more...");
      }
      else
      {
         alert=serverTime-symbolTime;
      }
 
raven_chrono:


Can you give any idea on how to monitor if a certain symbol is not updating. I mean accurately... because the EA is a no go then i shifted to scripts with this formula which will identify if the result is greater or equal to 5 minutes...

You need an infinite loop in your script, in start(), with a reasonable sleep, maybe a second or two to prevent your script using 100% of a CPU core. Also make sure to use IsStopped() as a condition in your loop, or the script won't terminate properly when you tell it to.

If you want to check the chart symbol use MarketInfo(Symbol(), MODE_TIME) as you did before . . . something like this:

int NoTickTime = 5;  // in minutes
int LocalTimeOffset;

init()
   {
   LocalTimeOffset = TimeCurrent() - TimeLocal();
   }


//  within the infinite loop in start()

if(MarketInfo(Symbol(),MODE_TIME) - LocalTimeOffset < TimeLocal() - ( NoTickTime * 60)  )
   {
   Alert("Symbol "+ Symbol() +" is not updating for 5 minutes or more...");
   }
 
RaptorUK:

You need an infinite loop in your script, in start(), with a reasonable sleep, maybe a second or two to prevent your script using 100% of a CPU core. Also make sure to use IsStopped() as a condition in your loop, or the script won't terminate properly when you tell it to.

If you want to check the chart symbol use MarketInfo(Symbol(), MODE_TIME) as you did before . . . something like this:


thanks...
 
raven_chrono:

thanks...
Hold on . . . need to think and fix.

OK, have a look now . . . the issue is that without any ticks the server time does not update . . . hence use Local time instead, but then you need to know the difference between Server time and Local Time and factor that in . . . you will need to add a check to e when the last alert was, otherwise the alert will be going off repeatedly when there hasn't been a tick . . .
 

hmm, what about a solution 'outside' of the terminal.exe: EXCEL or e.g. C++, Powershell.

1) You have to pass the ticks to EXCEL via DDE and there you should have a loop the checks the time of the last incoming tick. I think this is the fastest way but still needs a script running that has to be programmed.
2) Or if you run another terminl.exe may on a different account of different broker you can use for mt4 the already existing scripts that usese named pipes, but this way you will be trapped if your iinternet-connection broke: Both terminals will wait silently for the next tick...


3) Or you use the named-pipe (https://www.mql5.com/en/forum/127032) and on the other end of that pipe a program language like C++ (or powershell...)
3a) I think a named pipe could be enabled to work over the (inter-) net, so this way the controlling instance could catch if the server crashed..

4) May be you can find program snippets for receiving DDE-messages for those prg.-languages.


Beside that I would like to know how RefreshRates() works, it must collect new ticks bypassing start().

a) Is that correct: RefreshRates() by-passes start()?

b) What tick is presented to the EA: the most recent or just the next?


Good luck,

gooly