Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Встречайте учебник «Программирование на MQL5 для трейдеров»
fxsaber, 2024.04.05 09:23
From ME using CTRL+F1 on the function name you can immediately get to this help.
- www.mql5.com
Ok, but it does not work in the weekend on brokers that not provide crypto currency trading. There are many other ways to fix for example:
Forum on trading, automated trading systems and testing trading strategies
Possible bug in TimeTradeServer
amrali, 2024.04.07 18:56
For a better approach: check the terminal is connected to the trade server before using TimeTradeServer in indicators/experts
if(!TerminalInfoInteger(TERMINAL_CONNECTED)) { Print("Caution: Terminal is not connected, TimeTradeServer will be unreliable."); } //--- now it is safe to use the function datetime t = TimeTradeServer();
I suggest that TimeTradeServer() should be fixed to return 0 instead of TimeGMT, if the connection to the trade server is not yet established.
This will warn users that something wrong happened. Also setting the _LastError variable would be a good idea.
The result was the following code:
datetime TimeServer()
{ datetime tts=0;
datetime tc=TimeCurrent();
if (TerminalInfoInteger(TERMINAL_CONNECTED)) tts = TimeTradeServer();
if (tc>tts) return(tc);
else return(tts);
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Forum on trading, automated trading systems and testing trading strategies
Possible bug in TimeTradeServer
amrali, 2024.04.05 02:10
I am sorry for my previous responses. I re-checked and it seems to be a bug that affects TimeTraderServer() only inside indicators. Specifically, the bug occurs when the terminal is launched with an indicator ( that calls TimeTradeServer() ) is attached to the chart.
The returned value of TimeTradeServer() is wrong. It becomes equal to TimeGMT() inside OnInit() and also during the first 2 or 3 ticks until the terminal connects to the trade server (connected sound).
This is an obvoius bug in TimeTradeServer() in indicators. I file this bug report for MT5 developers team.
NOTICE: I checked experts advisors, luckily the bug DOES NOT happen there.
output: