I am getting the following error every time I try to enable an strategy. The strategy compiles just fine with no errors. The problem arises when I try to run strategy analyzer or enable it on a chart.
The error is:
Strategy 'XXXXXX': Error on calling 'OnBarUpdate' method on bar 11: Unable to cast object of type 'NinjaTrader.NinjaScript.Indicators.ATR' to type 'System.IConvertible'. |
#region Class Variables
private ATR Atr;
protected override void OnStateChange()
{
//Set defaults
if (State == State.SetDefaults)
{
BolPeriod = 9;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
//Create strategy indicators
Atr = ATR(Close, Convert.ToInt32(BolPeriod));
}
case 03:
EnterLongLimit(0, true, Convert.ToInt32(Order01LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.25 * TickSize), "LE01");;
EnterLongLimit(0, true, Convert.ToInt32(Order02LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.5 * TickSize), "LE02");
EnterLongLimit(0, true, Convert.ToInt32(Order03LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.75 * TickSize), "LE03");
break;
case 02:
EnterLongLimit(0, true, Convert.ToInt32(Order01LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.25 * TickSize), "LE01");;
EnterLongLimit(0, true, Convert.ToInt32(Order02LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.5 * TickSize), "LE02");
break;
case 01:
EnterLongLimit(0, true, Convert.ToInt32(Order01LotSize), Close[0] - (Convert.ToInt32(Atr) * 0.25), "LE01");
break;
#Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="BolPeriod", Description="Periodo Bollinger", Order=42, GroupName="Order Inputs")]
private int BolPeriod
{ get; set; }
Comment