I have created a Multi Time Frame Indicator, and I would like to be in M30 by default but can read, for example, Candles in D1, H4, H1 and M30 with iTime () iCLose () iOpen () etc ... I should download data everytime launching MT4
fly7680:I have
created a Multi Time Frame Indicator, and I would like to be in M30 by
default but can read, for example, Candles in D1, H4, H1 and M30 with
iTime () iCLose () iOpen () etc ... I should download data everytime launching MT4
In a standard indicator, you would build the buffer arrays with data from the parameters sent via the OnCalulate( ... ) event function. But, for multi-currency and/or multi-time-frame, you will have to use one of two solutions:
Using the old method of the "iFunction" variations, such as iTime(), iVolume, iOpen, iClose, etc. but with a different symbol such as "EURUSD", "JPYUSD", etc. instead of the default _Symbol or Symbol().
Using the newer method of the first variant of ArrayCopyRates() function together with array pointers of MqlRates. The "copied" arrays, will not actually take up any space and will just be pointers to the existing data of the various symbols and time-frames.
However, for this to work, one of two conditions have to exist for the multi-symbol and/or multi-time-frame to work:
Either the respective charts for the symbols and time-frames are already open, so that no error is generated,
or you will get an error 4066 (ERR_HISTORY_WILL_UPDATED) the first time you request the data, and you will have to code a sleep & retry loop, in order to wait for data to download and then request the data again.
My personal suggested solution, which I find as the most efficient as well as easiest way to handle the 4066 error, is the ArrayCopyRates() and MqlRates method.
There is more information about this the MQL4 documentation and help files.
PS! NB! When accessing built-in indicator functions, such as iMA(), iATR(), etc. for the various symbols and time-frames, remember to also implement the sleep and retry loops so as not to get the 4066 error either. Here is a quote from the MQL4 documentation:
Here I am again because I could not solve my problem and I do not understand where I am wrong...I show an image:

Any suggestions to resolve? Thank you all!!!Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
if I use different time frames, I should download M15, M30, H1, H4, D1 data with the function ?!?
I have created a Multi Time Frame Indicator, and I would like to be in M30 by default but can read, for example, Candles in D1, H4, H1 and M30 with iTime () iCLose () iOpen () etc ... I should download data every time launching MT4
@whroeder1 has already answered you in regards to that:
Be it multi-time-frame or multi-symbol, the concepts are similar, so read the following thread (from beginning to end) for some insight:
hello to all, I tried to do some tests to take the color of Heinke Hashi in D1 staying in M30 but it does not always work.
thanks