https://www.multicharts.com/trading-sof ... me_Profile
It works great most of the time, but about 2-3 times a day, I get this error popup, and the indicator status goes to "off". Once I turn it back "on" everything works fine again until the error happens again. Any idea what might be happening here?
ERROR POPUP
Code example from MultiChartsMessage: Error in study "my_indicator (@ES#C-1000 Tick)":
System.NullReferenceException: Object reference not set to an instance of an object.
at
PowerLanguage.Indicator.my_indicator.CalcBar()
at PowerLanguage.CStudyAbstract.DoExecute()
at
ManagedStudies.details.CUserStudyImpl.Body(CUserStudyImpl* )
Code: Select all
[SameAsSymbol(true)]
public class VA_Min_Max : IndicatorObject {
public VA_Min_Max(object _ctx):base(_ctx){}
private IPlotObject max_VA;
private IPlotObject min_VA;
protected override void Create() {
max_VA = AddPlot(new PlotAttributes("MaxVA", EPlotShapes.Line, Color.Red, Color.Black, 2, 0, true));
min_VA = AddPlot(new PlotAttributes("MinVA", EPlotShapes.Line, Color.Blue, Color.Black, 2, 0, true));
}
protected override void StartCalc() {
//subscribing for profile changes
VolumeProfile.EChanged += VolumeProfileOnEChanged;
}
protected override void CalcBar()
{
int bn = Bars.FullSymbolData.Current-1;
var vp = VolumeProfile.ItemForBar(bn);
if (vp != null)
{
max_VA.Set((double)vp.HighVAForBar(bn).Dbl );
min_VA.Set((double)vp.LowVAForBar(bn).Dbl );
}
}
private void VolumeProfileOnEChanged(bool full)
{
//Recalculate if the profile has been completely changed.
if (full)
this.ExecControl.Recalculate();
}
}