ATR Multi TimeFrame Issue
Created at 22 Jan 2019, 04:38
CY
ATR Multi TimeFrame Issue
22 Jan 2019, 04:38
Good Evening, I was trying to create a multi timeframe atr but i encountered some difficulties:
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class ATRMTF : Indicator { [Parameter()] public int per { get; set; } [Parameter()] public TimeFrame tf { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } public MarketSeries series; public IndicatorDataSeries tr, ema; protected override void Initialize() { tr = CreateDataSeries(); ema = Indicators.ExponentialMovingAverage(tr, per); series = MarketData.GetSeries(tf); } public override void Calculate(int index) { var index1 = series.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); tr[index1] = series.High[index1] - series.Low[index1]; Result[index] = ema.Result[index1]; } } }
i tought this was the right piece of code to do it, but when i change timeframe it only produces nan values.
is there a way to do it? i would really appreciate it since a lot of my algos use mtf ATR and I'm in a little bit of trouble with this.
Thanks in advance
PanagiotisCharalampous
22 Jan 2019, 10:17
Hi cysecsbin.01,
Here it is
Best Regards,
Panagiotis
@PanagiotisCharalampous