-
if (GMT_Time.hour==10) //timee.hour==8 { if(GMT_Time.min==34) //timee.min==0
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010) -
Wait for the proper time, disable until a new day.
Not tested, not compiled, just typed.
#define MAX_DATETIME D'3000.12.31 23:59:59' #define HR1034 (10*3600+34*60) void OnTick() { datetime now = TimeGMT(); static datetime todayDate=0; datetime todayPrev=todayDate; static datetime openTime; todayDate=date(now); if(todayDate != todayPrev) openTime=HR1034; // New day, enable. if(time(now) >= openTime){ openTime=MAX_DATETIME; // Time to trade, disable additional. // OHLC INFO ⋮ } }
Not tested, not compiled, just typed.
-
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010) -
Wait for the proper time, disable until a new day.
Not tested, not compiled, just typed.
Not tested, not compiled, just typed.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone, I'm new to coding, currently Im writing one that will open trade based on a specific time.
For example, if the current time is 21:00:00, and match the condition time, it will open a market order. However, the problem is the OnTick() function requests the order continously, it lead to 20-30 same positions in my trading tab.
Is there a way so I can request open a trade only (not by using OrderTotal, my further code cannot use that)
Below is my code (MQL5)