Download MetaTrader 5

Is there a maximum averaging period size for iATR? I'm getting some strange results...

To add comments, please log in or register
Publish your articles and improve your rating!
Benjamin Dixon
23161
Benjamin Dixon 2014.02.23 11:47 
iATR(Symbol(),0,3600,1) is reporting 0 even when Bars=3601. Also, when it finally starts returning a non 0 value (1000's of bars further), it still seems quite far off compared to the iATR with the same perimeters calculated by MT5 at the same spot.
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.02.23 11:52  
bendex77:
iATR(Symbol(),0,3600,0) is reporting 0 even when Bars=3601. Also, when it finally starts returning a non 0 value (1000's of bars further), it still seems quite far off compared to the iATR with the same perimeters calculated by MT5 at the same spot.
Do you have 3600 bars in your chart ?
Benjamin Dixon
23161
Benjamin Dixon 2014.02.23 12:01  
RaptorUK:
Do you have 3600 bars in your chart ?


Can I assume this if both iBars and Bars returns 3600 or more? I mean I didnt actually count each bar...
Benjamin Dixon
23161
Benjamin Dixon 2014.02.23 12:01  

this is in visual tester btw

Benjamin Dixon
23161
Benjamin Dixon 2014.02.23 12:15  
Actually in time the ATR of MT4 and MT5 both begin reporting the same value, its just the MT4 version is needing way more bars to be loaded (than the averaging period specified) to return a proper value... was wondering if its a known problem using such a huge averaging period....
Keith Watford
Moderator
9624
Keith Watford 2014.02.23 12:25  
bendex77:
iATR(Symbol(),0,3600,1) is reporting 0 even when Bars=3601. Also, when it finally starts returning a non 0 value (1000's of bars further), it still seems quite far off compared to the iATR with the same perimeters calculated by MT5 at the same spot.


How can you go 1000's of bars further than 1 ?

You can only go 1 bar further to 0.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.02.23 12:39  
bendex77:
Actually in time the ATR of MT4 and MT5 both begin reporting the same value, its just the MT4 version is needing way more bars to be loaded (than the averaging period specified) to return a proper value... was wondering if its a known problem using such a huge averaging period....
When the Strategy Tester starts you only have access to a limited number of bars to the left (in the past) . . . I have seen 100 or 1000 mentioned, certainly not 3600 . . . start your test earlier and fast forward to the date you want to actually start from then you will have more bars on the chart to work with.
Benjamin Dixon
23161
Benjamin Dixon 2014.02.23 19:57  
GumRai:


How can you go 1000's of bars further than 1 ?

You can only go 1 bar further to 0.


By 1000's further I mean 1000's more than the expected minimum requirement of 3600 bars "loaded" on to the chart (confirmed with iBars or Bars function) during visual testing.

When the Strategy Tester starts you only have access to a limited number of bars to the left (in the past) . . . I have seen 100 or 1000 mentioned, certainly not 3600 . . . start your test earlier and fast forward to the date you want to actually start from then you will have more bars on the chart to work with.

Yes I do do this but even when I have 3600 bars loaded (confirmed by either iBars or Bars function) iATR still returns 0 when I use a 3600 averaging period. It seems I need 7200 loaded on to the chart to get the proper result of 3600 period which seem odd. It could be a visual tester problem only.

Keith Watford
Moderator
9624
Keith Watford 2014.02.23 20:07  
bendex77:


By 1000's further I mean 1000's more than the expected minimum requirement of 3600 bars "loaded" on to the chart (confirmed with iBars or Bars function) during visual testing.

Yes I do do this but even when I have 3600 bars loaded (confirmed by either iBars or Bars function) iATR still returns 0 when I use a 3600 averaging period. It seems I need 7200 loaded on to the chart to get the proper result of 3600 period which seem odd. It could be a visual tester problem only.


If you are calculating an average on 3,600 bars, then it can only be calculated from shift (Bars - 3,600-1) or lower.

At shift(Bars-1) there are no values for the indi to use for calculations.

Benjamin Dixon
23161
Benjamin Dixon 2014.02.25 00:15  

Same thing when shift is 0. It does'nt include the first 3600 bars of the chart at all ever in its calculation and 7200 bars need to be loaded in to the chart to get a proper value when 3600 averaging period is specified even when shift is set to 0. for instance ATR at 3608 th bar (or earlier in time) processed in visual tester (counting from oldest/earliest bar towards newest...) is still reporting 0. At 5000 th bar it is way understated and becomes proper value at 7200 bars in to the visual tester session. 3600 bars should be enough to get an average of 3600 bars correct? NO! 7200 bars is needed for some reason in visual tester to get a proper value.

I have many choices to work around it, I was just wondering if it was a known bug.... or maybe its only in my terminal/ea for some reason.

Benjamin Dixon
23161
Benjamin Dixon 2014.03.16 08:56  
   
      if (Bars==3000) Print (iATR(Symbol(),Period(),3000,0)); //Prints 0
      if (Bars==4500) Print (iATR(Symbol(),Period(),3000,0)); //Prints about 0.5x of the proper ATR
      if (Bars==6000) Print (iATR(Symbol(),Period(),3000,0)); //Prints the correct ATR
12
To add comments, please log in or register