I am trying to figure out how to sell securities during the day while having a daily resolution for my indicators. For example, let's say my indicator gave me a signal for tomorrow to buy SPY. The backtest below does the right job of buying SPY at the opening price. In addition, I have added a profit target and stop loss orders which should be executed as soon as the target or stop loss has been hit, even if it is during the trading day. For example, let's say I buy SPY at the open at 300. During the day, it goes up to 304. My profit target is 1 dollar, so the algo should exit during the day as soon as the price goes above 301. Currently, the algo is waiting till the end of the day and sending the close order on the following day even when the profit target or stop loss was hit on the same day. Could someone please guide me on how to resolve this issue?   

Author