-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time, post in the correct place. The moderators will likely move this thread there soon. -
if((Hour()==1 && Minute()==5 && Seconds()==0)
Your code assumes that you will get a tick every second. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart.
-
You don't remember the value of counter (non-static/non-global)
-
static bool sent=false; #define HR0105 3900 // 60*3600+5*60 int now = time(); if(now < HR0105) sent=false; else if (!sent){ sent = true; OrderSend(Symbol(),OP_SELL,0.01,Bid,1,0,Bid-Take_Profit,"",111,0,Red); }
Find bar of the same time one day ago - MQL4 programming forum (2017) -
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014) -
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
-

- 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, I've tried to code a function that will make my EA take only 1 trade at specific time: 01:05 AM.
This is the code that I've typed but it doesn't work and I'm not sure why.
When I backtested it seemed to be working as the EA did take a trade at 01:05 but when I tried it on a live account it didn't take any trade.
Thanks in advance for any help.