End orders but not active trade
11/19/2023 at 1:41 PM #223918
Hello everyone, I’m very new to all of this so this is probably a basic question for you.
I want my pending orders to stop at a certain time but my code also stops any active trades. So far I have this:
How do I just let the active trades continue without being stopped?11/19/2023 at 5:13 PM #223927
Pending orders only last one bar. So you don’t need to cancel them. Just stop placing them after the time of your choice. This is valid for intraday timeframes.
If you are trading a daily timeframe you will need to resort to multiple timeframe, so that you can place pending orders in an intraday timeframe, stopping placing them when needed.11/19/2023 at 11:57 PM #22393711/20/2023 at 11:51 AM #22395911/20/2023 at 12:59 PM #223963
I want my pending orders to stop at a certain time but my code also stops any active trades.
Possibly you don’t realize that a “pending order” is a functional phenomenon which really is different than “a program code which must stop trading new orders”.
I think you refer to the latter. In that case, you should try to make something like this :1234567If Time >= 073000 and Time <= 083000 then// Here your code to enter new trades.endif// Here your code to exit trades, assumed you want this between 07:30 and 08:30.
A Pending Order is of the form12345Buy x Contracts at MyPrice Limit // Needs to be repeated each bar (= call of code).//orSell x Contracts at MyPrice Stop // Ditto.Buy x Contracts at Market // This is not a Pending order. It will execute immediately.11/22/2023 at 6:50 AM #22409911/22/2023 at 12:59 PM #22413311/24/2023 at 9:34 AM #224226