Closed pgrimstrup closed 5 months ago
@pgrimstrup thank you for contributing and sharing this issue. I'll look into this further soon to assess the situation. Here are a few similar issues.
I also see this in my list of known TradingView problems that I've previously reviewed.
@pgrimstrup any change in your perspective after reviewing my previous analyses here? I’d concluded that the TradingView author didn’t implement it in accordance with the original authors intent; and provided a few other reputable sources to back that up.
@pgrimstrup, do you have any open issues here? I don't believe there's an bug or issue with this library.
Please reopen if you disagree, or otherwise let us know how we can help.
the problem
Using the GetDonchian method to calculate Donchian Channels appears to be off by one time period. The new high/low is shown on the candle that is after the candle that triggered the new high/low.
Interestingly, the sample image on the Donchian Indicator page also shows this behavior. https://dotnet.stockindicators.dev/indicators/Donchian/#content
Checking the code, there appears to be an off-by-one error with the inner-loop calculation. The condition is currently
The condition should be (as it should include the current time period in the high/low calculation)
Correcting this appears to fix the problem, and new high/lows now begin on the correct candle.
Yes - comparing against Donchian Channel usage on TradingView where new high/lows start on the candle, not after it.
my situation
workaround
Implemented my own GetDonchian for now. Looking forward to an update.