Average True Range (ATR) free

by Hugoman in category Volatility at 26/02/2013

This Average True Range is based on the True Range Indicator provided by cTrader / cAlgo and has been overlayed with a simple Moving average. It is valid for all time frames and the period can be triggered by a parameter (default value is 14 units with respect to the chosen time frame)

Have fun and good trades

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
// -------------------------------------------------------------------------------
//							Average True Range (ATR)
// based on indicator 'True Range' and overlayed by simple Moving Average (SMA)
// -------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
    [Indicator("Average True Range", IsOverlay = false, ScalePrecision = 5, AccessRights = AccessRights.None)]
    public class AverageTrueRange : Indicator
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Average True Range", Color = Colors.Blue)]
        public IndicatorDataSeries ATR { get; set; }
		private IndicatorDataSeries tr;		
		private TrueRange tri;
		private MovingAverage TRMA;
        protected override void Initialize()
            // Initialize and create nested indicators
            tr = CreateDataSeries();
            tri = Indicators.TrueRange();
            TRMA = Indicators.MovingAverage(tr,Periods, MovingAverageType.Simple);            

        public override void Calculate(int index)
            // Calculate value at specified index            
            tr[index] = tri.Result[index];            
            ATR[index] = TRMA.Result[index];