I am drawing a large number of Vertical Lines successfully in a strategy. I current have 5 indicators which all use the same code snittip below. My problem is on the last indicator I cannot use these lines:
SellCrossVerticalLine.Stroke.Opacity = 15; // % transparent
SellCrossVerticalLine.Stroke.Width = 3; // 7 pixels wide
without returning this error:
Error on calling 'OnBarUpdate' method on bar 508: Object reference not set to an instance of an object.
It seems I am having a problem referencing the VerticalLine returned Object. I would like to test for its validity to furthor understand my problem. All of my vertical lines have a somewhat unique tag string
tag = ProcDescript = Instrument.FullName + "." + BarsPeriod.Value + "_" + Name + "_" + "_XBelow_" + Bars.GetTime(CurrentBars[0]).Minute
as you can see below. I understand for each indicator I will have 4 cases and each with a "Minute" base unique tag. I don't mind it they are overwritten intime.
When I run my set of Indicators in a strategy it will fail like mention above unless I comment out all references to the return VerticalLine object only in the Last indicator as written/refernced in the Strategey script.
Why is this happening? What can I do make this work consistantly?
Thank you for your time and consideration
Code Looks like this:
//************************************************** **********
//************** Turn UP or Turn Down ************************
//************************************************** **********
turnLong[0] = TurnUP(Values[2], 50.0, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
if (turnLong[0])
{
BuyTurnVerticalLine = Draw.VerticalLine(this, ProcDescript + "_TurnUP_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Green, DashStyleHelper.Solid, 2, false);
BuyTurnVerticalLine.Stroke.Opacity = 25;
BuyTurnVerticalLine.Stroke.Width = 5;
}
else
{
turnShort[0] = TurnDown(Values[2], 50.0, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
if (turnShort[0])
{
SellTurnVerticalLine = Draw.VerticalLine(this, ProcDescript + "_TurnDown_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Red, DashStyleHelper.Solid, 2, false);
SellTurnVerticalLine.Stroke.Opacity = 15; // % transparent
SellTurnVerticalLine.Stroke.Width = 5; // 7 pixels wide
}
}
crossLong[0] = XAbove(Values[1], Values[2], 50.0 , 1, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
if (crossLong[0])
{
BuyCrossVerticalLine = Draw.VerticalLine(this, ProcDescript + "_XAbove_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Green, DashStyleHelper.Solid, 2, false);
BuyCrossVerticalLine.Stroke.Opacity = 25;
BuyCrossVerticalLine.Stroke.Width = 3;
}
else
{
crossShort[0] = XBelow(Values[1], Values[2], 50.0 , 1, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
if (crossShort[0])
{
SellCrossVerticalLine = Draw.VerticalLine(this, ProcDescript + "_XBelow_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Red, DashStyleHelper.Solid, 2, false);
SellCrossVerticalLine.Stroke.Opacity = 15; // % transparent
SellCrossVerticalLine.Stroke.Width = 3; // 7 pixels wide
}
}
Comment