HighestFC & LowestFC functions

Questions about MultiCharts .NET and user contributed studies.
joenetic
Posts: 30
Joined: 13 Jun 2013

HighestFC & LowestFC functions

Postby joenetic » 11 Mar 2017

Anyone know why this indicator code without compile error, but execute has error of System.NullReferenceException?

using System;
using System.Drawing;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]

public class Channel_Breakout : IndicatorObject
{
private HighestFC m_HighestFC;
private LowestFC m_LowestFC;

private IPlotObject Plot1;
private IPlotObject Plot2;

public Channel_Breakout(object ctx) :
base(ctx){
length = 20;
}

private ISeries<double> Price { get; set; }

[Input]
public int length { get; set; }



protected override void Create(){

m_HighestFC = new HighestFC(this);

m_LowestFC = new LowestFC(this);

Plot1 =
AddPlot(new PlotAttributes("UpperBand", 0, Color.Yellow,
Color.Empty, 0, 0, true));
Plot2 =
AddPlot(new PlotAttributes("LowerBand", 0, Color.Blue,
Color.Empty, 0, 0, true));

}

protected override void StartCalc(){
Price = Bars.High;
m_HighestFC.pricevalue = Price;
m_HighestFC.len = length;
}


protected override void CalcBar(){
var upperband = m_HighestFC[0];
var lowerband = m_LowestFC[0];

Plot1.Set(0, upperband);
Plot2.Set(0, lowerband);


}
}
}

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: HighestFC & LowestFC functions

Postby darob » 13 Mar 2017

Hi joenetic, there's no lower band references in StartCalc(), maybe that's the problem.


Return to “MultiCharts .NET”