I started to derive a Rectangle class into a alertRectangle class in the DrawingTools namespace.
Later on, in an indicator I try to get all the drawing objects where type match this alertRectangle class:
However, I am facing an error about type conversion
Indicator 'ZoneAlert': Error on calling 'OnBarUpdate' method on bar 0:
[A]NinjaTrader.NinjaScript.DrawingTools.alertRectangl e can't be converted to [B]NinjaTrader.NinjaScript.DrawingTools.alertRectangl e.
A Type comes from '9d4d7d2f09f04fe49d12ce01eabf724f, Version=8.0.23.0, Culture=neutral, PublicKeyToken=null' in the 'LoadFrom' context at 'E:\Documents\NinjaTrader 8\tmp\9d4d7d2f09f04fe49d12ce01eabf724f.dll'.
B type comes from '3f856e8638064373b63654f121ff80ee, Version=8.0.23.0, Culture=neutral, PublicKeyToken=null' in the 'LoadFrom' context at 'E:\Documents\NinjaTrader 8\tmp\3f856e8638064373b63654f121ff80ee.dll'.
I already delete the tmp folder, restarting ninjatrader several times.
However this error still persist
Here is the code (abstract)
public class alertRectangle : Rectangle
{
protected override void OnStateChange()
{
base.OnStateChange();
if (State == State.SetDefaults)
{
Description = @"Design an alert rectangle.";
Name = "alertRectangle";
...
blablabla
...
}
else if (State == State.Configure)
{
}
}
//Condition condition
#region Properties
[NinjaScriptProperty]
[Display(Name = "Condition", GroupName = "Alert Condition", Order = 0)]
public Condition condition
{ get; set; }
[Range(0, int.MaxValue), NinjaScriptProperty]
[Display(Name = "ReactivationDelay", GroupName = "Alert Condition", Order = 1)]
public int delayBeforeReactivation
{ get; set; }
[NinjaScriptProperty]
[Display(Name = "Keep alive", GroupName = "Alert Condition", Order = 2)]
public bool stayAlive
{ get; set; }
#endregion
public bool Notified;
public DateTime? NotifiedTime;
}
foreach (DrawingTool draw in DrawObjects.ToList())
{
if (draw.GetType().Name == "alertRectangle")
{
// This is failing on thje line:
alertRectangle globalRectangle = (DrawingTools.alertRectangle)draw;
alertRectangle globalRectangle = draw as DrawingTools.alertRectangle;
Can you help ?

Comment