My OnBarUpdate() is occurring on the bar close - important to the strategy.
Expected Result:
The first bar closes and entry conditions are met
The ATM order enters
The ATM order fills
The ATM stop or target is filled and the other is cancelled
At the close of the bar in which the ATM stop or target executed, if entry conditions are met, enter a new ATM order
Actual Result:
I run into the limitation that the ATM order won't be recognized as completed until the close of the following bar, which would be a whole bar after the desired second entry.
I think I might be able to work around this limitation. I'd like to know feedback or other solutions if you have them. I'm not entirely sure how I would implement my solution below.
- OnBarClose, the ATM strategy enters and it fills
- The ATM strategy will automatically create 2 orders: my stop and target
- I need to get these 2 orderIds that were just created
- I would then "monitor" when the order status of these 2 orders changes
- If they are filled/cancelled, I can set a bool flag
- When the bar closes, that bool flag will be read and a new entry would be made.
Comment