I'm doing something wrong, I just can't figure out what. I'm trying to do the following (in this order):
1) Go short
2) Exit short
3) Go long
When I get to the third step, I somehow end up with 2 contracts when I should only have one. Here's a more in-depth look at what I do for each step.
1) Go short by calling EnterShort(1, "Tx"). By using TraceMode I get this:
9/29/2009 10:05:58 AM Entered internal PlaceOrder() method at 9/29/2009 10:05:58 AM: Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Tx' FromEntrySignal=''
9/29/2009 10:05:58 AM Entered internal PlaceOrder() method at 9/29/2009 10:05:58 AM: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=66.32 SignalName='S-Tx' FromEntrySignal='Tx'
From OnExecution when this order is filled I set a stop loss by calling ExitLong(0, true, execution.Order.Filled, LastStopPrice, "S-Tx", "Tx"). LastStopLoss is a value I calculate.
2) From OnBarUpdate when some exit condition is met I call ExitShort("Tx") to exit the condition. TraceMode tells me this:
9/29/2009 10:06:17 AM Entered internal PlaceOrder() method at 9/29/2009 10:06:17 AM: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='Tx'
3) Right after #2 (I don't wait for a fill, maybe this is why...) I want to enter long by calling EnterLong(1, "Tx")
9/29/2009 10:06:17 AM Entered internal PlaceOrder() method at 9/29/2009 10:06:17 AM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Tx' FromEntrySignal=''
9/29/2009 10:06:17 AM Cancelled pending exit order, since associated position is closed: Order='e1f8ca889a40498182edfeef32c0d6e7/Replay101' Name='S-Tx' State=Accepted Instrument='CL 11-09' Action=BuyToCover Limit price=0 Stop price=66.32 Quantity=1 Strategy='PeterATR' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='e1f8ca889a40498182edfeef32c0d6e7' Gtd='12/1/2099 12:00:00 AM'
So, any clue why I end up with 2 contracts instead of one?
Thank you.
Comment