Hi,
Can anyone help debugging why orders don't close in my automated backtesting?
I cannot find any errors in my "code", but the auto backtest doesn't behave as expected.
I created an exit rule that should close an order automatically when the current bar low breaks the low of the last 20 bars counting from the previous bar using the Donchian Channel indicator. I've attached a screenshot to illustrate. It also shows the Core rule which is used in the Exit rule.
Any ideas to what is causing my issue?
Cheers!
-Martin
Order doesn't auto close (bug or user error?)
-
- Posts: 18
- Joined: Sun Dec 04, 2022 2:59 pm
Order doesn't auto close (bug or user error?)
- Attachments
-
- 01 order should close.png (566.74 KiB) Viewed 3672 times
-
- Posts: 259
- Joined: Tue Feb 22, 2022 11:06 am
Re: Order doesn't auto close (bug or user error?)
Hello,
It looks like your core rule compares the low of the last candle (position 0) with the value of the indicator of the before last candle (position 1).
Thus, this condition is never filled since the positions of the candles are different.
If you try to set the position to 0 (lastbar) in the indicator value, it should work
It looks like your core rule compares the low of the last candle (position 0) with the value of the indicator of the before last candle (position 1).
Thus, this condition is never filled since the positions of the candles are different.
If you try to set the position to 0 (lastbar) in the indicator value, it should work
-
- Posts: 18
- Joined: Sun Dec 04, 2022 2:59 pm
Re: Order doesn't auto close (bug or user error?)
Hi,
I tried that, but unfortunately, it doesn't help. If I set the indicator to 0, the position never closes.
With my current rule (indicator set to 1), at least the position closes, but later than expected (as illustrated in the second screenshot).
Any ideas?
Cheers!
I tried that, but unfortunately, it doesn't help. If I set the indicator to 0, the position never closes.
With my current rule (indicator set to 1), at least the position closes, but later than expected (as illustrated in the second screenshot).
Any ideas?
Cheers!
- Attachments
-
- 02 closes too late.png (612.82 KiB) Viewed 3659 times
-
- Posts: 259
- Joined: Tue Feb 22, 2022 11:06 am
Re: Order doesn't auto close (bug or user error?)
You're using the Donchian Channel indicator, which is for the lower band, the lowest value of the candles. So, it's not possible that the low of the last can be lower than the lower Donchian Channel.
If you want to trigger the condition, you can use "less or equal" instead of "less" operator, and set the bar position to 0, not 1. Otherwise the comparison is not consistent.
Thus, this should work
If you want to trigger the condition, you can use "less or equal" instead of "less" operator, and set the bar position to 0, not 1. Otherwise the comparison is not consistent.
Thus, this should work