From the chart:
5/17/2000 > Open = 4.19 / High = 5.12 / Low = 4.19 / Close = 5.12
5/18/2000 > Open = 5.06 / High = 5.38 / Low = 4.94 / Close = 5.12
5/19/2000 > Open = 5.06 / High = 5.25 / Low = 4.87 / Close = 5.19
From the print window:
5/19/2000 4:00:00 AM -> Submitting EnterLong order for CHK (entrySignal = LONG-CHK-96) - Last Close = 5.12
5/18/2000 2:00:00 PM Entered internal PlaceOrder() method at 5/18/2000 2:00:00 PM: BarsInProgress=70 Action=Buy OrderType=Market Quantity=19,531 LimitPrice=0 StopPrice=0 SignalName='LONG-CHK-96' FromEntrySignal=''
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = LONG-CHK-96 // Order State = PendingSubmit
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = LONG-CHK-96 // Order State = Accepted
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = LONG-CHK-96 // Order State = Working
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = LONG-CHK-96 // Order State = Filled
5/18/2000 2:00:00 PM In OnExecution() Function // Order = LONG-CHK-96 // Order State = Filled // Order Fill Price = 5.06
5/18/2000 2:00:00 PM In OnExecution() Function - Updating initial stop - Current Ask Price = $5.12 // Current Bid Price = $5.12 // Last Open = 5.06 // Last Close = 5.12
5/18/2000 2:00:00 PM CALCULATING INITIAL STOP (Instrument = CHK) - Last Close = 5.12 - Stop Price = $4.97
5/18/2000 2:00:00 PM Entered internal PlaceOrder() method at 5/18/2000 2:00:00 PM: BarsInProgress=70 Action=Sell OrderType=Stop Quantity=19,531 LimitPrice=0 StopPrice=4.97 SignalName='InSTOP_L-CHK-95' FromEntrySignal='LONG-CHK-96'
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = InSTOP_L-CHK-95 // Order State = PendingSubmit
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = InSTOP_L-CHK-95 // Order State = Accepted
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = InSTOP_L-CHK-95 // Order State = Working
5/18/2000 2:00:00 PM In OnOrderUpdate() Function // Order = InSTOP_L-CHK-95 // Order State = Filled
5/18/2000 2:00:00 PM In OnExecution() Function // Order = InSTOP_L-CHK-95 // Order State = Filled // Order Fill Price = 4.97
5/18/2000 2:00:00 PM In OnExecution() Function - STOP TRIGGERED! - Fill Price = 4.97
What I want to do:
1) Submit an order using EnterLong
2) As soon as possible after the buy order has been filled, submit a stop loss order using ExitLongStop(), calculated based on the current price
I understand that a buy order won't be filled until the next bar - that's no problem. However, my understanding was that the OnExecution function would only be called after the order was filled (i.e, at the open of the day after the order was submitted in the backtest). If that were the case, then wouldn't I be able to submit a stop order in that function, and have it be based off of the fill price of the order?
Hopefully I've explained this properly - I'm really scratching my head over here
Thanks
Comment