Issue with built-in ATR indicator

Created at 04 Sep 2016, 01:53
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
jhtrader's avatar

jhtrader

Joined 15.10.2013 Blocked

Issue with built-in ATR indicator
04 Sep 2016, 01:53


I am getting the wrong value when backtesting a bot containing the following code:

The Bot is running on the 1 minute timeframe for the trade pair EURUSD and the backtesting period is between 17/08/2016 and 02/09/2016

 protected override void OnStart()
        {

            MarketSeries m = MarketData.GetSeries(TimeFrame.Hour);
            Print("mTest O = {0}|H {1}|L {2}|C {3} @ {4} - {5} {6}", m.Open.Last(1), m.High.Last(1),m.Low.Last(1),m.Close.Last(1), m.OpenTime.Last(1), m.SymbolCode.ToString(), m.TimeFrame.ToString());
            AverageTrueRange atrHourly = Indicators.AverageTrueRange(MarketData.GetSeries(TimeFrame.Hour), 120, MovingAverageType.VIDYA);
            Print("Current Hrly ATR 120 VIDYA for Time:{0} is {1}", m.OpenTime.Last(1), atrHourly.Result.Last(1));
            double HourlySwingSpace = (atrHourly.Result.Last(1) * SwingSpaceMultiplier);


        }

The Log contains: 

 17/08/2016 00:00:00.000Current Hrly ATR 120 VIDYA for Time:16/08/2016 10:00:00 PM is 0.000480434550042612 

 17/08/2016 00:00:00.000mTest O = 1.1275|H 1.1281|L 1.12749|C 1.1277 @ 16/08/2016 10:00:00 PM - EURUSD Hour 

 17/08/2016 00:00:00.000Backtesting started  

NOTE The value for the Hourly Bar is CORRECT however the value printed for the ATR value that is NOT AS Expected it should be 0.00203.

 

 

 


Replies

croucrou
04 Sep 2016, 16:05

Aren't you missing this part:

var index = m.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

 


@croucrou