Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please always use the CODE button (Alt-S) when inserting code.
Just saying it "does not work" means nothing. We have no idea what you mean by it, nor can we see what you expect.
Explain in detail, provide screenshots and show the output from the logs.
EDIT: Also, please note that when acquiring data from a different time-frame from the one being tested you have to synchronise the data and handle 4066/4073 errors.
Forum on trading, automated trading systems and testing trading strategies
William Roeder, 2022.08.16 14:57
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
Just saying it "does not work" means nothing. We have no idea what you mean by it, nor can we see what you expect.
Explain in detail, provide screenshots and show the output from the logs.
Here is the EDIT: Also, please note that when acquiring data from a different time-frame from the one being tested you have to synchronise the data and handle 4066/4073 errors.
Here is the ouptput I get when i run the code in live/strategy tester (m1) i am expecting some values for the m5
Current bar for XAUUSD M5: 1970.01.01 00:00:00, 0.0, 0.0, 0.0, 0.0, 0

- docs.mql4.com
i checked the logs - i do not see any errors in it
also the history center option to download data says - data is current no new data available
rjngh2005 #:
Here is the ouptput I get when i run the code in live/strategy tester (m1) i am expecting some values for the m5
Current bar for XAUUSD M5: 1970.01.01 00:00:00, 0.0, 0.0, 0.0, 0.0, 0
Current bar for XAUUSD M5: 1970.01.01 00:00:00, 0.0, 0.0, 0.0, 0.0, 0
Did you correct your code according to the advice given in my post?
Also, please note that when acquiring data from a different time-frame from the one being tested you have to synchronise the data and handle 4066/4073 errors.
Forum on trading, automated trading systems and testing trading strategies
William Roeder, 2022.08.16 14:57
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
Did you correct your code according to the advice given in my post?
Also, please note that when acquiring data from a different time-frame from the one being tested you have to synchronise the data and handle 4066/4073 errors.
this correction is required if there are errors
however in my logs i see no errors
//+------------------------------------------------------------------+ //| tstOtherCandle.mq4 | //| Copyright 2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property strict bool New_Bar=false; datetime New_Time=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- Fun_New_Bar(); if(New_Bar==false) return; Print(", Time ",New_Time, ",Open value ,",Open[1],",Close value ,",Close[1],", Open value M5,",iOpen(_Symbol,PERIOD_M5,1),", Close value M5,",iClose(_Symbol,PERIOD_M5,1)); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Fun_New_Bar() { New_Bar=false; if(New_Time !=Time[0]) { New_Time=Time[0]; New_Bar=true; } } //+------------------------------------------------------------------+
here is the final code which is working fine
Thanks a lot everyone

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The following code does not work - please help
I am trying to run this code in strategy tester on period M1
basically i want the open/close/high/low of the M5 candle
to figure out the problem i even changed the 0 to 1 in all the code
I ran this code in strategy tester for 12/01/2024 - 12/15/2024
this code is from https://docs.mql4.com/series/itime