• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 B11- PB-MR - Error on calling "OnPositionUpdate" method on bar 64473:

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    NT8 B11- PB-MR - Error on calling "OnPositionUpdate" method on bar 64473:

    NT8 B11- Playback-Market Replay

    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].





    Code:
    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
    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.
    2016-05-29 20:09:03:576 (Playback Connection) Cbi.Account.AccountItemCallback: account='Playback101' accountItem=CashValue currency=UsDollar value=*****



    Code:
    		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 ++;
    			}
    	
    		}

    #2
    Hello sledge,

    Thank you for your note.

    I got rid of all the printing used except for the Flat part. I would try commenting out the Closes[ES] and then the PositionStatus to see if they are causing this message.

    Here is the simplified code I reviewed:
    Code:
    		protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition )
    		{
    			if ( marketPosition == MarketPosition.Flat )
    			{
    				Print ( "strategy1 A 2 OnPositionUpdate.MarketPosition=" + "FLAT" );
    
    				
    				PositionStatus = FLAT;
    				Print ( ToDay (Time[0]) + "," + ToTime(Time[0]) + ",ES," + "Flat: " + Closes[ES][0]  );
    			}
    			else if (marketPosition == MarketPosition.Long)
    			{
    				PositionStatus = LONG;
    			}
    			else if (marketPosition == MarketPosition.Short)
    			{
    				PositionStatus = SHORT;
    			}
    	
    		}
    Patrick H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NinjaCustomer, Yesterday, 11:35 PM
    0 responses
    2 views
    0 likes
    Last Post NinjaCustomer  
    Started by sdauteuil, Yesterday, 11:29 PM
    0 responses
    1 view
    0 likes
    Last Post sdauteuil  
    Started by williamzz, Yesterday, 09:50 PM
    0 responses
    19 views
    0 likes
    Last Post williamzz  
    Started by Steve L, Yesterday, 05:01 PM
    0 responses
    6 views
    0 likes
    Last Post Steve L
    by Steve L
     
    Started by Trader-Joe, Yesterday, 04:06 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Working...
    X