Error on calling "OnPositionUpdate" method on bar 64473: Index was outside the bounds of the array.
This one makes little sense.
I have been using this OnPositionUpdate in all my strategies since last fall at least. Ran in Beta 11 with only 2 tabs on ES03-16 and ES06-16. I started on 12/15/2015 and strategy was disabled around 1/7/2016. That probably is the correct count, I'm using 15 second bars for the ES. And I have no reference to anything other than [0].
2016-05-29 20:09:03:569 (Playback Connection) Cbi.Simulator.Fill1: orderId='c83ee407365c430696157535e0a14a96' maxFillQuantity=4 price=1985.5 thread=36 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Simulator.Fill2: orderId='c83ee407365c430696157535e0a14a96' fillQuantity=4 price=1985.5 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.OrderUpdateCallback: orderId='c83ee407365c430696157535e0a14a96' account='Playback101' name='Profit target' orderState=Filled instrument='ES 03-16' orderAction=BuyToCover limitPrice=1985.5 stopPrice=0 quantity=4 orderType='Limit' filled=4 averageFillPrice=1985.5 error=NoError comment='' 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Order.OrderUpdateCallback.HandleOco.TriggerCancel: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=Cancelled instrument='ES 03-16' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=2015.5 quantity=4 tif=Gtc oco='eb5b80b20e5b4133870145f5205e075e' filled=0 averageFillPrice=0 onBehalfOf='' id=31 gtd='2099-12-01' currentOrderState=TriggerPending 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.Cancel0: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=Cancelled instrument='ES 03-16' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=2015.5 quantity=4 tif=Gtc oco='eb5b80b20e5b4133870145f5205e075e' filled=0 averageFillPrice=0 onBehalfOf='' id=31 gtd='2099-12-01' currentOrderState=TriggerPending 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.OrderUpdateCallback: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=CancelPending instrument='ES 03-16' orderAction=BuyToCover limitPrice=0 stopPrice=2015.5 quantity=4 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment='' 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.Cancel1: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=Cancelled instrument='ES 03-16' orderAction=BuyToCover orderType='Market' limitPrice=0 stopPrice=2015.5 quantity=4 tif=Gtc oco='eb5b80b20e5b4133870145f5205e075e' filled=0 averageFillPrice=0 onBehalfOf='' id=31 gtd='2099-12-01' currentOrderState=CancelPending 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.OrderUpdateCallback: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=CancelSubmitted instrument='ES 03-16' orderAction=BuyToCover limitPrice=0 stopPrice=2015.5 quantity=4 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment='' 2016-05-29 20:09:03:569 (Playback Connection) Cbi.Account.OrderUpdateCallback: orderId='877e4b66f7004ab4985584b3cee316e5' account='Playback101' name='Stop loss' orderState=Cancelled instrument='ES 03-16' orderAction=BuyToCover limitPrice=0 stopPrice=2015.5 quantity=4 orderType='Market' filled=0 averageFillPrice=0 error=NoError comment='' 2016-05-29 20:09:03:570 (Playback Connection) Cbi.Account.ExecutionUpdateCallback: executionId='cf93204e927043aeb1420bde2941592b' account='Playback101' instrument='ES 03-16' exchange=Globex price=1985.5 quantity=4 marketPosition=Long operation=Add orderID='c83ee407365c430696157535e0a14a96' isSod=False time='01/04/2016 11:00:05' statementDate='2016-01-04' 2016-05-29 20:09:03:570 (Playback Connection) Cbi.Account.PositionUpdateCallback: instrument='ES 03-16' account='Playback101' avgPrice=0 quantity=0 marketPosition=Flat operation=Remove [B]2016-05-29 20:09:03:571 ERROR: Strategy 'strategy1/76032086': Error on calling 'OnPositionUpdate' method on bar 64473: Index was outside the bounds of the array. [/B]2016-05-29 20:09:03:576 (Playback Connection) Cbi.Account.AccountItemCallback: account='Playback101' accountItem=CashValue currency=UsDollar value=*****
protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition ) { //Print ( "strategy1 A 1a marketPosition=" + marketPosition.ToString() ); //Print ( "strategy1 A 1b position.MarketPosition=" + position.MarketPosition.ToString() ); if ( marketPosition == MarketPosition.Flat ) //if (marketPosition.ToString()[0] == 'F' ) //if (position.MarketPosition == MarketPosition.Flat) { Print ( "strategy1 A 2 OnPositionUpdate.MarketPosition=" + "FLAT" ); PositionStatus = FLAT; Print ( ToDay (Time[0]) + "," + ToTime(Time[0]) + ",ES," + "Flat: " + Closes[ES][0] ); //Print ( "strategy1 A SysPerf.AllTrades.Count=" + SystemPerformance.AllTrades.Count ); //Print ( "strategy1 A SysPerf.RTTrades.Count =" + SystemPerformance.RealTimeTrades.Count ); //if (SystemPerformance.AllTrades.Count > 0) //{ // Trade lastTrade = SystemPerformance.AllTrades[TotalTrades-1]; //Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]; //Trade firstTrade = Performance.AllTrades.LosingTrades[0]; //Print ( "strategy1 A LastTrade was "+ lastTrade.ProfitPoints ); //} } else if (marketPosition == MarketPosition.Long) //else if (marketPosition.ToString()[0] == 'L' ) //else if (position.MarketPosition == MarketPosition.Long) { //Print ( "strategy1 A 2 OnPositionUpdate.MarketPosition=" + "LONG" ); PositionStatus = LONG; //NumberOfTrades ++; } else if (marketPosition == MarketPosition.Short) //else if (marketPosition.ToString()[0] == 'S' ) //else if (position.MarketPosition == MarketPosition.Short) { //Print ( "strategy1 A 2 OnPositionUpdate.MarketPosition=" + "SHORT" ); PositionStatus = SHORT; //NumberOfTrades ++; } }
Comment