I have a problem with position.quantity I´m working with now for months. I have no idea whats going on.
Output window shows from Onbarupdate where I do print together with the entry (Print("Position.Quantity: " + Position.Quantity); Print(Time[0])
17.11.2013 04:35:51
Position.Quantity: 0
But there is a trade with 3 contracts and output window shows from my OnPosition with Print("OnPosition.Position.Quantity: " + Position.Quantity);Print(Time[0])
contractskL1a 1
17.11.2013 04:35:51
OnPosition.Position.Quantity: 1
17.11.2013 04:35:51
contractskL1b 2
17.11.2013 04:35:51
OnPosition.Position.Quantity: 2
17.11.2013 04:35:51
contractskL1c 3
17.11.2013 04:35:51
OnPosition.Position.Quantity: 3
Why is Pos.Qty from OnBarUpdate=0? OK, I can live with, maybe this is to fast with the entry and NinjaTrader needs to count up in OnExecution or OnPosition. No Problem when in OnbarUpdate the PosQty is not correct. But it should be correct and working from OnPosition. The problem is that my exits do not work because conditions Position.Quantity==3 is not true:
if(Position.MarketPosition == MarketPosition.Long)
{if(Position.Quantity==3
&& GetCurrentBid() > Position.AvgPrice + 10 * TickSize)
{exitOrder1a = ExitLong(1);}
There is no exit! I assume because Pos.Qty is not 3 in Onbarupdate (as shown in output window) How can this be that Pos.Qty is different? How can I refer in my conditions to correct Pos.Qty from OnPosition please?
Thank you
Tony
Comment