Refactor documentation for various filters and indicators to enhance clarity and consistency

- Updated Bessel, Bilateral, Blma, Butter, Conv, Ema, Kama, LSMA, MAMA, MGDI, SSF, USF, ATR, ADL, and ADOSC documentation to use bullet points for key concepts and features.
- Added a new Qodana configuration file for code analysis.
- Removed coverage configuration from Quantower.Tests.csproj to streamline testing setup.
This commit is contained in:
Miha Kralj
2025-12-31 23:39:47 -08:00
parent 11f4ec2497
commit d493bfd42f
175 changed files with 11977 additions and 897 deletions
+63
View File
@@ -0,0 +1,63 @@
# DC: Donchian Channels
## Overview and Purpose
Donchian Channels are a versatile technical analysis tool developed by Richard Donchian in the mid-20th century. This indicator creates a price channel consisting of three lines: an upper band tracking the highest high over a specified period, a lower band tracking the lowest low, and a middle band representing the average of these extremes. Donchian Channels effectively visualize price volatility and potential support/resistance levels by highlighting the range within which prices have fluctuated over the lookback period.
## Core Concepts
* **Range identification:** Donchian Channels excel at defining dynamic support and resistance levels based on actual price extremes rather than statistical measures
* **Market application:** Particularly effective for breakout trading strategies, trend identification, and volatility assessment across various market conditions
* **Timeframe suitability:** **Multiple timeframes** work well, with shorter periods (10-20) for short-term trading signals and longer periods (20-55) for identifying significant support/resistance zones
Donchian Channels differ from other volatility-based channels (like Bollinger Bands) by using actual price extremes rather than statistical deviations, making them especially useful for trend-following strategies and breakout systems.
## Common Settings and Parameters
| Parameter | Default | Function | When to Adjust |
| --------- | ------- | -------- | -------------- |
| Period | 20 | Controls the lookback window for calculation | Decrease for more sensitivity to recent price action, increase for more stable channels |
| High Source | High | Data point used for upper band calculation | Change to different price data only for specific, specialized strategies |
| Low Source | Low | Data point used for lower band calculation | Change to different price data only for specific, specialized strategies |
**Pro Tip:** The "Donchian Channel Breakout" strategy, popularized by the Turtle Traders, traditionally uses a 20-day breakout for entry signals and a 10-day breakout in the opposite direction for exits. This asymmetric application often yields better results than using the same period for both.
## Calculation and Mathematical Foundation
**Simplified explanation:**
Donchian Channels track the highest high and lowest low over a specified period. For each bar, the indicator identifies the highest high and lowest low over the lookback period, then calculates a middle line as the average of these two extremes.
**Technical formula:**
Upper Band = Highest High of last n periods
Lower Band = Lowest Low of last n periods
Middle Band = (Upper Band + Lower Band) / 2
Where:
* n is the specified lookback period
* Highest High is the maximum high price observed during the period
* Lowest Low is the minimum low price observed during the period
> 🔍 **Technical Note:** The implementation uses monotonic deques with circular buffers for efficient calculation, maintaining O(1) time complexity for each new bar rather than repeatedly scanning the entire lookback period.
## Interpretation Details
Donchian Channels provide multiple trading signals and insights:
* **Breakout trading:** Price breaking above the upper band signals potential bullish momentum, while breaking below the lower band indicates potential bearish momentum
* **Range identification:** The width of the channel represents market volatility—wider channels indicate higher volatility
* **Trend strength:** In strong trends, price tends to "walk" along either the upper or lower band
* **Mean reversion:** The middle band often acts as a magnet for price, especially after extended moves to the outer bands
Traders may also use channel width (difference between upper and lower bands) as a standalone volatility measure to adjust position sizing or identify potential market regime changes.
## Limitations and Considerations
* **Market conditions:** Less effective during sideways, choppy markets where repeated false breakouts may occur
* **Lag factor:** By definition, the indicator is backward-looking and may not adapt quickly to sudden market changes
* **False signals:** Brief price spikes can trigger false breakout signals, especially with shorter lookback periods
* **Complementary tools:** Best combined with volume analysis, momentum indicators, or other confirmation tools to filter potential false signals
## References
* Schwager, J. D. (1989). Market Wizards: Interviews with Top Traders. New York: Harper & Row.
* Faith, C. (2007). The Original Turtle Trading Rules. Original Turtles.
+50
View File
@@ -0,0 +1,50 @@
// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Donchian Channels (DCHANNEL)", "DCHANNEL", overlay=true)
//@function Calculates the Donchian Channel (DC) efficiently using monotonic deques
//@param hi Source series for the highest high calculation (usually high)
//@param lo Source series for the lowest low calculation (usually low)
//@param p Lookback period (p > 0)
//@returns Tuple containing [basis, upper_band, lower_band]
//@optimized Uses monotonic deque for O(1) amortized complexity per bar
dchannel(series float hi, series float lo, simple int p) =>
if p <= 0
runtime.error("Period must be > 0")
var float[] hbuf = array.new_float(p, na)
var float[] lbuf = array.new_float(p, na)
var int[] hq = array.new_int()
var int[] lq = array.new_int()
int idx = bar_index % p
array.set(hbuf, idx, hi)
array.set(lbuf, idx, lo)
while array.size(hq) > 0 and array.get(hq, 0) <= bar_index - p
array.shift(hq)
while array.size(hq) > 0 and array.get(hbuf, array.get(hq, -1) % p) <= hi
array.pop(hq)
array.push(hq, bar_index)
while array.size(lq) > 0 and array.get(lq, 0) <= bar_index - p
array.shift(lq)
while array.size(lq) > 0 and array.get(lbuf, array.get(lq, -1) % p) >= lo
array.pop(lq)
array.push(lq, bar_index)
float top = array.get(hbuf, array.get(hq, 0) % p)
float bot = array.get(lbuf, array.get(lq, 0) % p)
[math.avg(top, bot), top, bot]
// ---------- Main loop ----------
// Inputs
i_period = input.int(20, "Period", minval=1)
i_high = input.source(high, "High Source")
i_low = input.source(low, "Low Source")
// Calculation
[basis, upper, lower] = dchannel(i_high, i_low, i_period)
// Plot
plot(basis, "Basis", color=color.yellow, linewidth=2)
p1 = plot(upper, "Upper", color=color.yellow, linewidth=2)
p2 = plot(lower, "Lower", color=color.yellow, linewidth=2)
fill(p1, p2, color=color.new(color.blue, 90), title="Band Fill")