The Code File attached which i learned from MQL4 Tutorial. The Code run on Back test but unable to run in live trading. Why ?
Files:
Trading_Time.mq4
2 kb
What is happening in live trading? Was is written in the logs? Have you tried the debugger?
Raj Tandon :
The Code File attached which i learned from MQL4 Tutorial. The Code run on Back test but unable to run in live trading. Why ?
The Code File attached which i learned from MQL4 Tutorial. The Code run on Back test but unable to run in live trading. Why ?
Lots of errors,
try this:
// Input parameters for trading time input string StartTradingTime = "03:00" ; // Trading start time input string StopTradingTime = "18:00" ; // Trading stop time bool TradingIsAllowed = false ; // Variable to check if trading is allowed void OnTick () { // Get the current local time datetime time = TimeLocal (); string CurrentTime = TimeToString (time, TIME_MINUTES ); // Check if trading is allowed based on the time range TradingIsAllowed = CheckTradingTime(CurrentTime); // If trading is allowed and there are no open orders, place a new order if (TradingIsAllowed && OrdersTotal () == 0 ) { OrderSend ( NULL , OP_BUY, 0.01 , Ask, 3 , 0 , Ask + 150 * _Point , NULL , 0 , 0 , Green); } // Display information on the chart Comment ( "Trading Allowed: " , TradingIsAllowed, "\n" , "Current Time: " , CurrentTime, "\n" , "Start Trading Time: " , StartTradingTime, "\n" , "Stop Trading Time: " , StopTradingTime, "\n" ); } //+------------------------------------------------------------------+ // Function to check if the current time is within the trading time range bool CheckTradingTime( string CurrentTime) { // If the current time is within the range, allow trading if (CurrentTime >= StartTradingTime && CurrentTime <= StopTradingTime) { return true ; } return false ; }
Thanks for sending code. I add this code to my EA. Now I will watch on when my trade condition will true and EA send order or not
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

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