I get an error
Indicator 'zzTrend': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object.
Look in attach please, there is a simple indicator which use ZigZag indicator, but there is an error. I need help
private Series<double> zzH;
private Series<double> zzL;
private double DeviationValue = 0.14;
...
if (State == State.Configure) {
zzH = ZigZag(DeviationType.Points, DeviationValue, true).ZigZagHigh;
zzL = ZigZag(DeviationType.Points, DeviationValue, true).ZigZagLow;
}
and then in OnBarUpdate
I call
Print (Time[0].ToString()+" ZZH[0]="+ZigZag(DeviationType.Points, DeviationValue, true).ZigZagHigh[0] + " ZZH[2]="+ZigZag(DeviationType.Points, DeviationValue, true).ZigZagHigh[2]+"\n"+"ZZL[0]="+ZigZag(DeviationType.Points, DeviationValue, true).ZigZagLow[0] + " ZZL[2]="+ZigZag(DeviationType.Points, DeviationValue, true).ZigZagLow[2]);
and this code works fine
BUT
whte I change call to
Print (Time[0].ToString()+" ZZH[0]="+zzH[0] + " ZZH[2]="+zzH[2]+"\n"+"ZZL[0]="+zzL[0] + " ZZL[2]="+zzL[2]);
Then I get an error Indicator 'zzTrend': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object.
What do I wrong in this simple code example?
Comment