MicroTrendsLtd / NinjaTrader8

NinjaTrader8 Components Strategies and Trading tools
MIT License
75 stars 20 forks source link

ATSSamplePriceReversal index error #38

Closed ipsidhu closed 3 years ago

ipsidhu commented 3 years ago

got these error on two different charts with live data.

2020.12.11 10:41:01:210 Strategy "ATSSamplePriceReversalTest"/218221722 Realtime Short Realtime GoLongClosedPositionsPending:>OnOrderUpdate >> Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List1.RemoveAt(Int32 index) at System.Collections.Generic.List1.Remove(T item) at NinjaTrader.NinjaScript.Strategies.ATSQuadroStrategyBase.OnOrderUpdate(Order order, Double limitPrice, Double stopPrice, Int32 quantity, Int32 filled, Double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, String comment) 2020.12.11 10:41:01:410 Strategy "ATSSamplePriceReversalTest"/218221722 Realtime Short Realtime GoLongClosedPositionsPending:>OnOrderUpdate(↑Close#218 OrderId=6fce5a34b12f484eb29d887883baf6be State=Filled)


2020.12.11 10:41:01:210 Strategy "ATSSamplePriceReversalTest"/218221722 Realtime Short Realtime/SimAccount3 NQ 12-20 (720 Tick) t:88|BT=2020.12.11 10:41:02:687|HR=R|CB=435|LC=12320.25|RX=11|RO=348|MP=S|PQ=1|AO=1|SQ=0|WF=GoLongClosedPositionsPending:>OnOrderUpdate >> Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List1.RemoveAt(Int32 index) at System.Collections.Generic.List1.Remove(T item) at NinjaTrader.NinjaScript.Strategies.ATSQuadroStrategyBase.OnOrderUpdate(Order order, Double limitPrice, Double stopPrice, Int32 quantity, Int32 filled, Double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, String comment)

Thanks Tom and James for all your hard work.

best, Inder

MicroTrendsTom commented 3 years ago

possibly might a race condition and needs a lock on an object prior to contains and remove order from list... Just wondering if this occurs a lot or was a one off?

ipsidhu commented 3 years ago

Yea maybe it was race condition as i have not seen it since. Should close #38 Thanks

Sent from my iPhone

On Dec 14, 2020, at 3:43 AM, Tom Leeson notifications@github.com wrote:

 possibly might a race condition and needs a lock on an object prior to contains and remove order from list... Just wondering if this occurs a lot or was a one off?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

MicroTrendsTom commented 3 years ago

ok awesome for the feedback will leave open to keep me reminded and look at some patterns. then will close a bit later ty 👍

MicroTrendsTom commented 3 years ago

fixed by code refactor and subsequent testing in that area