JLLMNCHR: just one operation at a day (at 10:15 pm). Does the
next code do what I want?
No it does not.
- You are trying to get the first event at the proper time and then every day after that. The first event will not be exact. The after that will slowly drift, later and later.
- You will also get events, when the market is closed (week ends.)
- Don't try to use any price or server related functions in
OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
#define HR2215 80100 // (22*60+15)*60 void OnTick(){ const SECONDS when = HR2215; datetime now = TimeCurrent(); SECONDS tod = time(now); static datetime nextEvent = 0; if(nextEvent == 0 && tod > when) nextEvent = tomorrow(); // Start up after when. if(tod < when // Waiting for the time. || nextEvent > now) return; // Previously handled. nextEvent = tomorrow(); // No more today. // Do it }
Find bar of the same time one day ago - Simple Trading Strategies - MQL4 and MetaTrader 4 - MQL4 programming forum
Thats is awesome! I'll try as soon as posible.
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 want to develop an EA in mql4 that open just one operation at a day (at 10:15 pm).
For this kind of systems, perhaps OnTick event handler is unnecessary.
Does the next code do what I want?