private int GetTickValuePosAvgToTP(Order order)
{
int tickValue = 0;
if (order == null || Position == null)
return 0;
try
{
tickValue = Position.MarketPosition == MarketPosition.Long ? (int)((order.LimitPrice - Position.AveragePrice) / TickSize)
: Position.MarketPosition == MarketPosition.Short ? (int)((Position.AveragePrice - order.LimitPrice) / TickSize)
: 0;
}
catch (Exception ex)
{
string errorMsg = string.Format("[" + this.GetType().Name + "][" + MethodBase.GetCurrentMethod().Name + "]-[ERROR]-{0}", ex.ToString());
Debug.Print(errorMsg);
Print(errorMsg);
Log(errorMsg, LogLevel.Error);
}
return (int)Instrument.MasterInstrument.RoundToTickSize(tickValue);
}
02.03.2021 18:16:45:000 > [SidiSystemBase][OnOrderUpdate]-[ERROR]-System.IndexOutOfRangeException: Der Index war außerhalb des Arraybereichs.
bei NinjaTrader.NinjaScript.StrategyBase.get_Position( )
bei NinjaTrader.NinjaScript.Strategies.SidiSystemBase. GetTickValuePosAvgToTP(Order order)
can someone tell me where to look for the error ;-) i am currently stuck looking for IndexOutOfRangeException. where in the code could the error even occur?

Comment