Download MetaTrader 5

Custom Indicator and multi pairs problem

To add comments, please log in or register

I have a custom indicator which simply returns/shows HLOC on the chart attached.

Now, I am trying to create another custom indicator which uses the first one.

This second indi opens handles using first indicator for different symbols  than the current chart.

I simply want to calculate in the second indicator some data using HLOC prices from other symbols via first indicator.

After a lot of tries I get shit-ed and can not solve the problem. The second indicator does not want to work. It keeps saying AnotherSymbol has not data calculated yet;

The second indicator uses 4 other symbols , eg GBPJPY,USDJPY,GBPCHF,USDCHF. It says for example USDJPY first indi data is not ready but doesnt say anything about the other pairs.

If I change the symbols handle opening for first indicator (in the second indicator) like this: GBPJPY,GBPCHF,USDCHF,USDJPY it says the GBPCHF is not ready. Etc ...

I wrote this indicator in MT4 quite easily and no problems. I do have also quite good experience in coding and dont think I do code mistakes too many.

I read almost all in docs but nothing appears to solve my problem; I dont know where to go forward.

I am getting frustrated working with MQL 5 now  (shit! :)


Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
Rashid Umarov
Rashid Umarov  

yes, I did. Not too much help for me.

In that  indicator, in OnCalculate it calls



for 7 pairs where each pair has a buf allocated in indicator; so 7 buffs

shiftbars = 500; so , on each oncalculate , it copies the whole arrays of data, 500 bars for each pair; it is not a good idea ..

ok, we can make shiftbars = 30 but it is still unpractically to copy data for 30 bars back for 7 pairs on each call of oncalculate; and this for close only

It is acceptable this when prev_calculated is 0 , first time, but later, when only 1 or 2 bars back need recalculated , only these bars should be copied. 

There is there also an ini_tf() method but that is just a croppy example method to synchronize 

In my case, I would need to work with 8 pairs using all their HLOC data, so I would need 8 * 4 = 32 buff for a minimum 50 bars back; it is not practically to copy them on each oncalculate.

And the big question for me is:

We have 2 symbols S1 and S2,  each has in history enough data for 200 H1 bars for a given period and so, the terminal can build the arrays of H1 HLOC data for that period of bars.

Suppose, the S2 has missing data on server and history local for 10 hours in a given period but enough to be built 200 bars like S1.

The question is, are the times of that 200 bars the same for both S1 and S2 ? eg. same time on same shift on both S1 and S2 ?

thank you. 




To add comments, please log in or register