I'm building a TradeStation strategy for automated execution (robot trader).
I want the ability to enter and exit mid-bar, or in a subsequent bar.
i.e. If conditions are met at 7 minutes into a fifteen minute bar, the entry or exit will be executed immediately without waiting for open of next bar. On the other hand; if conditions are not met for several bars, the strategy will execute mid-bar (of a subsequent bar) when conditions are met.
I am using "[IntrabarOrderGeneration = TRUE]" and coding as follows:
If MP=0 and H=H then buy this bar;
MP = 1;
If MP=1 and H=H-.25 then sell this bar;
MP = 0;
The exit is working, and will get me out instantly, but the entry is not. It delays until the open of the next bar.
How should I code the entry statement to execute instantly when conditions are met (in current or future bars)?
welcome to futures.io. When using intrabar order generation in Tradestation "Next bar" orders will be executed at the next tick that is processed, while "this bar" orders will only be processed at the end of the bar. That's why you are getting your orders filled at the open only.