Okay, so I’ve progressed to the point of having my Indicator create orders when the appropriate entry triggers appear.
Before I get too far into my rather complicated trade management system, however, I need to know why the event triggers don’t seem to be triggering on the actual events. It would appear that they are only running when OnBarUpdate does, if even then.
Wednesday - NQ
Wednesday - NQ
A - Order = Filled, Position =
D - Order = Filled, Position =
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Execution updated.
Order: Entry Quantity: 1 Price: 30142.25
Open position = instrument=‘NQ 06-26’ account=‘Playback101’ avgPrice=30142.25 quantity=1 marketPosition=Long statementDate=‘2099-12-01’
Order updated.
Stop price: 0 Quantity: 2 Limit price: 0
Execution updated.
Order: Entry Quantity: 1 Price: 30142.5
In this excerpt from my Output1 tab, you see the “Wednesday - NQ” report, which is generated by an Indicator that does nothing but toggle a boolean that is visible to the main Indicator to determine, based on time-of-day, whether I am in a valid trading window or not.
The A and D order output comes from the main Indicator, and those print lines are in OnBarUpdate.
Finally, you see the “Order updated.” report, which comes from OnOrderUpdate.
Later, you see the execution update information, which comes from OnExecutionUpdate.
This issues are these:
I was already in a position at the time of the first two output lines. The A and D lines use a variable, the value of which is supposed to be there after the "Position = ", that is populated by OnPositionUpdate. As you can see, that variable is still null, even though I am already in a position.
Eventually, the “Open position” report, from OnPositionUpdate does show up, but again, it’s only after I’ve already been in a position for at least 40 seconds (two bars on my 20-sec. chart).
And the OrderUpdate and ExecutionUpdate also take the same 40 seconds to fire, despite the fact that both of those events must have happened for me to get into the position in the first place.
So, when do these event triggers actually fire? I would have thought it would be as soon as the actual event takes place. But here, I am having to wait a long time for these event triggers to act, and it is preventing me from executing logic based on what the state of things is the instant I enter a position.
Any help would be appreciated. Thank you!