MultiTimeFrame Indicator only shows up in original Timeframe
MultiTimeFrame Indicator only shows up in original Timeframe
23 Nov 2017, 23:28
Hi Folks,
currently I'm trying to build are rather simple Indicator. It should provide the previous days high and low no matter what timeframe I am working in.
My first shoot is to use the multitimeframe indicator posted /forum/whats-new/1463.
I modified it to show just the previous days high, code looks like this:
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class SigKissDax : Indicator { [Output("DaxDailyHigh", Color = Colors.Red)] public IndicatorDataSeries DaxDailyHigh { get; set; } private MarketSeries series24h; protected override void Initialize() { series24h = MarketData.GetSeries(TimeFrame.Daily); } public override void Calculate(int index) { var index24h = GetIndexByDate(MarketSeries, series24h.OpenTime[index]); if (index24h != -1) { DaxDailyHigh[index] = series24h.High[index]; } } private int GetIndexByDate(MarketSeries series, DateTime time) { for (int i = series.Close.Count - 1; i > 0; i--) { if (time == series.OpenTime[i]) { return i; } else if (series.OpenTime[i] < time) { return i; ; //return last value prev. to desired } } return -1; } } }
Since I am usually working in timeframes smaller than one day I switched the MarketSerie going into GetIndexByDate since I want to take the 24hseries.opentime and find the closest matching index of my current timeframe.
The indicator calculates and if displayed in its original timeframe (daily) shows correct results. but in other timeframes it displays no results at all?!
Any Ideas?
THX
PanagiotisCharalampous
24 Nov 2017, 10:05
Hi Mikro,
You should reverse the inputs in the GetIndexByDate function. See below
Let me know if this helps,
Best Regards,
Panagiotis
@PanagiotisCharalampous