-
NULL is not -1.
-
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)On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019) - Just take time[i] and extract the date. Done.
Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)Remember to handle the case where start > end (e.g. 2100 … 0200)
I am writing a custom indicator and trying to print Daily time but its giving NULL (-1)
int myiBarShift(ENUM_TIMEFRAMES TF, datetime time) { int ret = iBarShift(Symbol(), TF, time, false)-1; if (ret<0) ret=0; if (ret>iBars(Symbol(), TF)) ret = iBars(Symbol(), TF); for (int j=ret; j<iBars(Symbol(), TF); j++) if (iTime(Symbol(), TF, j) <time) return((j-1>=0)?j-1:0); return(-1); }
use this, for me better than built-in
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use