ATR on different TF

Created at 18 Feb 2019, 10:49
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!
alexander.n.fedorov's avatar

alexander.n.fedorov

Joined 02.01.2018

ATR on different TF
18 Feb 2019, 10:49


Dear Panagiotios,

 

How do you find ATR on diffrent TimeFrame, say monthly?

 

Regards, 

 

Alexander


@alexander.n.fedorov
Replies

PanagiotisCharalampous
18 Feb 2019, 11:34

Hi Alexander,

The built in indicator does not support this. You will need to develp your own indicator.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
18 Feb 2019, 12:13

Thanks, Panagiotis

Regards, Alexader


@alexander.n.fedorov

GDPR-83_694920
27 Feb 2019, 19:38

Hi

Not sure if I am understanding this correctly but I was using this ATR Hugoman built and posted in the Indicators Section until I realised it was possible to use built in indicators and ever since I have been using the built in ATR so this post got me worried it is not actually working MTF so quickly put together the below code to test and MTF on built in ATR seems to be working fine (or as I say perhaps I am misunderstanding something somehwere here!?)

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        private AverageTrueRange ATRM5;
        private AverageTrueRange ATRM15;
        private AverageTrueRange ATRH;
        private AverageTrueRange ATRD;

        private MarketSeries TFSM5;
        private MarketSeries TFSM15;
        private MarketSeries TFSH;
        private MarketSeries TFSD;

        protected override void OnStart()
        {
            TFSM5 = MarketData.GetSeries(TimeFrame.Minute5);
            TFSM15 = MarketData.GetSeries(TimeFrame.Minute15);
            TFSH = MarketData.GetSeries(TimeFrame.Hour);
            TFSD = MarketData.GetSeries(TimeFrame.Daily);

            ATRM5 = Indicators.AverageTrueRange(TFSM5, 14, MovingAverageType.Exponential);
            ATRM15 = Indicators.AverageTrueRange(TFSM15, 14, MovingAverageType.Exponential);
            ATRH = Indicators.AverageTrueRange(TFSH, 14, MovingAverageType.Exponential);
            ATRD = Indicators.AverageTrueRange(TFSD, 14, MovingAverageType.Exponential);
        }

        protected override void OnTick()
        {
            double ATRMinute5 = Math.Round(ATRM5.Result.LastValue, Symbol.Digits);
            double ATRMinute15 = Math.Round(ATRM15.Result.LastValue, Symbol.Digits);
            double ATRHour = Math.Round(ATRH.Result.LastValue, Symbol.Digits);
            double ATRDaily = Math.Round(ATRD.Result.LastValue, Symbol.Digits);

            Print("M5 {0}  M15 {1}  H {2}  D {3}", ATRMinute5, ATRMinute15, ATRHour, ATRDaily);
        }
    }
}

 


PanagiotisCharalampous
28 Feb 2019, 09:40

Hi Max T,

Your solution is correct. It was my oversight that I did not notice this overload.

Best Regards,

Panagiotis


@PanagiotisCharalampous

GDPR-83_694920
28 Feb 2019, 14:37

I don't honestly know what an overload actually is haha ;) and am amazed I actually got something 'right' (relatively new to C# and cAlgo) but good to know it does work thanks for confirming!


PanagiotisCharalampous
28 Feb 2019, 14:41

Hi Max T,

:) Here is what it is.

Best Regards,

Panagiotis


@PanagiotisCharalampous