Reference custom indicator
Created at 16 Feb 2019, 12:10
Reference custom indicator
16 Feb 2019, 12:10
Hi,
I tried to reference this custom indicator "ZeroLagEMA" from spka111 (https://ctrader.com/algos/indicators/show/145)
to be used in my custom indicator "ZLMACD", but only NaN shows in my indicator.
No idea what's wrong with my indicator. (I'm a newbie coder)
Hope someone can help to point out the error in my code.
Thanks.
//#reference : ..\Indicators\ZeroLagEMA.algo using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = false)] public class ZLMACD : Indicator { private ZeroLagEMA ma1; private ZeroLagEMA ma2; [Parameter()] public DataSeries Source { get; set; } [Parameter(DefaultValue = 14, MinValue = 5)] public int X1 { get; set; } [Parameter(DefaultValue = 14, MinValue = 5)] public int X2 { get; set; } [Output("Main", Color = Colors.LimeGreen)] public IndicatorDataSeries Result { get; set; } [Output("Main1", Color = Colors.Red)] public IndicatorDataSeries Result1 { get; set; } [Output("Main2", Color = Colors.Yellow)] public IndicatorDataSeries Result2 { get; set; } protected override void Initialize() { ma1 = Indicators.GetIndicator<ZeroLagEMA>(Source, X1); ma2 = Indicators.GetIndicator<ZeroLagEMA>(Source, X2); } public override void Calculate(int index) { Result[index] = Source[index] - ma1.Result[index]; Result1[index] = Source[index] - ma2.Result[index]; Result2[index] = Result[index] - Result1[index]; } }
PanagiotisCharalampous
18 Feb 2019, 12:05
Hi joshc1092,
You have entered the parameters the wrong way round. See below the correct way
Best Regards,
Panagiotis
@PanagiotisCharalampous