Execute MQL Code on External Event

 

Is there any way to execute a code on an external event instead of executing thre code on every tick? For example when a .txt file in MQL/Files folder gets refreshed.

 

The idea is to send information/quotes to MT4 by an external (e.g. Java coded) program. This (Java coded) program creates/refreshes a .txt file inside MQL/Files folder.

An MQL EA would read the information from the .txt file. 

However if it would read the .txt file in OnTick() function, this would only happen on every MT4 tick.

 

I would like the code to get executed every time the (Java coded) program refreshes the .txt file.

Is there anyway to do this?

A "solution" by using MillisecondTimer to read every xx ms would not be an option for me.

 

Thank you very much in advance! 

 

Yes put it in OnMillisecondTimer() in stead of OnTick()

You dont want it in ontick but you also dont want it in ontimer ?

Whats left

 
Marco vd Heijden:

Yes put it in OnMillisecondTimer() in stead of OnTick()

You dont want it in ontick but you also dont want it in ontimer ?

Whats left

Not a solution because if you set MillisecondTimer to 1ms code will get executed only around every 15ms which is not sufficient for my purpose.

Also it could probably cause quite some load if the code is executed all the time.

For example, there is a FIX to MT4 application that brings quotes to MT4 I think by using offline chart, but I don't know how to do that. Just an idea.

 
jan100: Not a solution because if you set MillisecondTimer to 1ms code will get executed only around every 15ms which is not sufficient for my purpose.

Also it could probably cause quite some load if the code is executed all the time.

For example, there is a FIX to MT4 application that brings quotes to MT4 I think by using offline chart, but I don't know how to do that. Just an idea.

Have a look at my SpreadTracker source code. It uses the technique (Windows Message Posting) you have just described: https://www.mql5.com/en/code/10983

Spread Tracker
Spread Tracker
  • votes: 2
  • 2013.09.20
  • Fernando Carreiro
  • www.mql5.com
Tracking Variable Spreads with an Offline Chart
 

Thanks a lot!

 

If the information is sent via Windows Message Posting from the (Java coded) program, how can I make MT4 execute code on this event (when windows message is posted)?

 
jan100: If the information is sent via Windows Message Posting from the (Java coded) program, how can I make MT4 execute code on this event (when windows message is posted)?
I have no idea how your code works. All that "Message" does in my code is generate a message update event, that can indirectly generate a call to OnTick(), that is all.
Reason: