Forcing strategy execution 5 minutes before the end of the day
Author: BCode
Creation Date: 2/24/2017 12:14 AM
profile picture


I have developed a trading system that uses a 60 minute scale. This means that every hour the strategy executes with the last executable execution happening at 3:30pm EST. When signals are generated at 3:30pm I can execute my trades no problem. However at market close, my strategies automatically execute again (4pm EST) which more often than not leaves me with buy or sell signals that I can't execute. When manually trading I can keep track of these and execute at market open, however when paper trading any orders that get placed at 4pm get immediately cancelled and then I can't do anything with the orders.

What I would like to do is force my strategy to execute at 3:55pm so I can place all orders before the close and then not let the strategy execute at 4pm to eliminate the issue I have encountered. Anyone have any idea how to go about doing this?

profile picture


The only automated way to do this is to use a smaller interval.. 5 minute bars to execute at 3:55, or 1 minute bars for 3:59, etc.

You can still run the strategy using indicators from the 60 minute scale by creating and synchronizing indicators with SetScaleCompressed(). However, if you need to update those indicators at 3:55 in order to generate signals, then you have to go an extra step to create a partial bar result. I have routines to do that for a handful of standard indicators (SMA, Stoch, etc.).

Finally, in the smaller scale, it's trivial to avoid to executing the strategy after any given time.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).