y not use
struct MqlTick { datetime time; // Time of the last prices update double bid; // Current Bid price double ask; // Current Ask price double last; // Price of the last deal (Last) ulong volume; // Volume for the current Last price };
BHC:
You can now use the OnTimer() event handler, with EventSetTimer(), see Mql4 reference by pressing F1 in MetaEditor.
I would like to run my EA at a predefined interval irrespective of when/ if the EA gets any new ticks from the server. I am trying something like this
My question is, can it be possible to have the start (or 'OnTick') function run in parallel with my main code.
With this code can I be sure a new tick will not stop the running of my other code?
angevoyageur:
You can now use the OnTimer() event handler, with EventSetTimer(), see Mql4 reference by pressing F1 in MetaEditor.
You can now use the OnTimer() event handler, with EventSetTimer(), see Mql4 reference by pressing F1 in MetaEditor.
OnTimer is not working...
Am using OnTick with the above code… hope this is resolved soon.
BHC:
OnTimer() is working well (build 610), what you have tried ?
OnTimer is not working...
Am using OnTick with the above code… hope this is resolved soon.
BHC: OnTimer is not working...
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
- Did you turn on the timer? MQL4 Documentation
I set the timer like in mql5
BHC:
My EA with only the on timer was placing no trades. When I placed 'Print' statements in the timer function nothing was appearing in terminal log. Only OnTick was printing.
Show your code if you need help.
My EA with only the on timer was placing no trades. When I placed 'Print' statements in the timer function nothing was appearing in terminal log. Only OnTick was printing.
angevoyageur:
Show your code if you need help.
Show your code if you need help.
I have the same problem ( Version: 4.00 Build 610 (14 Feb 2014), the test code is below:
define N_minutes 5 int OnInit() { EventSetTimer(60*N_minutes ) ; Print("Error GetLastError() = ", GetLastError() ) ; return(INIT_SUCCEEDED); } void OnTimer() { Print(" !!! Timer_in !!!") ; }I'm working with MB Trading FX, may be this new functionality is vendor dependent(?)
Thanks
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to run my EA at a predefined interval irrespective of when/ if the EA gets any new ticks from the server. I am trying something like this
My question is, can it be possible to have the start (or 'OnTick') function run in parallel with my main code.
With this code can I be sure a new tick will not stop the running of my other code?