Hi,
I am trying to figure out how to close my open trade after 3-4 bars after the trade is open, regardless of floating profit/loss.
I have tried the below and it's not working.
Would someone be able to provide some help?
Close all open trades after X bars
-
- Posts: 259
- Joined: Tue Feb 22, 2022 11:06 am
Re: Close all open trades after X bars
Hi,
Could you be more specific please ?
For example, do you want to close you open trade always after a specific amount of elapsed bars or it depends on your timeframe ?
In the first case, it's not yet possible but we can add additional rules for that.
In the second case, you can obtain the open time of a trade and eventually compare it with the current backtest time.
In your screenshot, we can see that you compare the monthly days of the bar in position 1 and position 4, it will always happen since the bar in position 1 will be always more recent than the one in position 4, except at the beginning of a new month
Could you be more specific please ?
For example, do you want to close you open trade always after a specific amount of elapsed bars or it depends on your timeframe ?
In the first case, it's not yet possible but we can add additional rules for that.
In the second case, you can obtain the open time of a trade and eventually compare it with the current backtest time.
In your screenshot, we can see that you compare the monthly days of the bar in position 1 and position 4, it will always happen since the bar in position 1 will be always more recent than the one in position 4, except at the beginning of a new month
Re: Close all open trades after X bars
I am trying to achieve the below:
On the daily timeframe:
If:
Candle(1)close>candle(1)open
&&
Candle(2)=close<candle(2)open
Then:
Buy (mkt) 0.1 (as an example)
And:
On the 1 hour timeframe:
Close trade during 4th daily candle at 11am (AEST)
See the below:
On the daily timeframe:
If:
Candle(1)close>candle(1)open
&&
Candle(2)=close<candle(2)open
Then:
Buy (mkt) 0.1 (as an example)
And:
On the 1 hour timeframe:
Close trade during 4th daily candle at 11am (AEST)
See the below:
-
- Posts: 259
- Joined: Tue Feb 22, 2022 11:06 am
Re: Close all open trades after X bars
Thanks for providing the details, this is easier to understand for us with this example.
So, as we understand, you want to close your open order always after the 4th candle has closed.
At the moment, this is not possible but we can add a rule for that.
Let's say we call it "order duration", this rule could be compared with a new "timespan" rule : expressed by a number of bars or a real timespan (just like current order expiration for pending order).
The condition would be in the exit rule :
IF "order duration" >= "timespan (4 bars)" THEN
-> Close the current trade
Would it okay for you like that ?
So, as we understand, you want to close your open order always after the 4th candle has closed.
At the moment, this is not possible but we can add a rule for that.
Let's say we call it "order duration", this rule could be compared with a new "timespan" rule : expressed by a number of bars or a real timespan (just like current order expiration for pending order).
The condition would be in the exit rule :
IF "order duration" >= "timespan (4 bars)" THEN
-> Close the current trade
Would it okay for you like that ?
Re: Close all open trades after X bars
Yes, I would like to try using an order duration (timespan) rule.
Thanks!
Thanks!