Download MetaTrader 5

new indicator structure ..

To add comments, please log in or register
Do you want to learn MQL5? 300 articles will help you!
Carl Schreiber
Carl Schreiber 2014.09.09 15:45 


after I realized a problem of the way mt4 is painting a second indicator in the same indicator sub-window:

If you apply the ATR-14 at the chart (extra sub-window) and you pull this ATR again from the Navigator in this window and define a 7-Period,

you will experience that e.g. the ATR-7 is painted above the ATR-14 even though the value of the ATR-7 is smaller than the ATR-14.

As you can see at the last bar ATR-7 is smaller than ATR-14 but in the upper sub-chart ATR-7 is painted above ATR-7. (I wrote to the Service-Desk, but got now answer).

So I took the default Atr and added a second array to calculate and show an ATR with another Period (lower sub-window). As you see that calculated values in both sub-windows are the same but the picture differs and might mislead manual traders.

Doing this I realized that at first all the serialized quotes arrays are 'turned around':

int OnCalculate(...) {

The former Bar[0] becomes now Bar[Bars] or Bar[rates_total] which is right now 12'875.

Does  anybody knows how the 'ArraySetAsSeries()' is executed? Either some flags are switched (every new tick) or the whole array is copied every new tick.

Beside that does anybody know how it is detected that in case of iCustom(.. 0,0) = the most recent bar which in old indicators is the bar[0] too but now it's Atr's bar[Bars]?

Which is the fastest way as there most be a lot of checks to find the right set fro the requesting EA?

Is the reason the compatibility with Mql5 or is there another reason for the change of the policy?

Regards, Gooly

Ian Venner
Ian Venner 2014.09.09 16:19  

The array is indexed according to ArraySetAsSeries on every tick. I don't think thinks it is a time consuming process as the values are not moved, just the indexing direction is changed.

As for iCustom I am not sure, you might find you have to set shift to rates_total-1 instead of zero.

I noticed MQ has done that to many of the included indicators since they updated the code to build 600.

Also MQ has said the indexing order of the series arrays is not guaranteed so really we all should be setting the indexing explicitly, why MQ chose to reverse them from the old series array direction I am not sure, perhaps it makes for a faster loop.

To add comments, please log in or register