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
+62
View File
@@ -0,0 +1,62 @@
# PCHANNEL: Price Channel
## Overview and Purpose
The Price Channel is a simple volatility-based indicator that plots the highest high and the lowest low over a user-defined lookback period. It is very similar in concept and application to Donchian Channels. The channel visually represents the trading range of an asset over the specified period.
A middle line, typically the average of the upper and lower channel lines, can also be plotted to serve as a mean reference.
## Core Concepts
* **Highest High:** The upper band represents the highest price reached during the lookback period.
* **Lowest Low:** The lower band represents the lowest price reached during thelookback period.
* **Trading Range:** The channel effectively shows the price extremes for the chosen period.
* **Breakout Indication:** Prices moving above the upper channel or below the lower channel can signal potential breakouts and the start of new trends.
## Common Settings and Parameters
| Parameter | Default | Function | When to Adjust |
| :-------- | :------ | :------- | :------------- |
| Length | 20 | Lookback period for determining the highest high and lowest low. | Shorter lengths make the channel more reactive to recent price action; longer lengths create a wider, smoother channel representing longer-term ranges. |
## Calculation and Mathematical Foundation
**Simplified explanation:**
1. For each bar, look back over the specified `Length`.
2. Identify the absolute highest `high` price during that period. This forms the Upper Channel line.
3. Identify the absolute lowest `low` price during that period. This forms the Lower Channel line.
4. (Optional) The Middle Channel line is the average of the Upper and Lower Channel lines: `(Upper Channel + Lower Channel) / 2`.
**Technical formula:**
1. **Upper Channel:**
`UpperChannel = Highest(High, Length)`
2. **Lower Channel:**
`LowerChannel = Lowest(Low, Length)`
3. **Middle Channel (optional):**
`MiddleChannel = (UpperChannel + LowerChannel) / 2`
## Interpretation Details
* **Support and Resistance:** The upper band can act as resistance, and the lower band as support.
* **Breakouts:**
* A close above the Upper Channel suggests bullish strength and a potential upside breakout.
* A close below the Lower Channel suggests bearish pressure and a potential downside breakout.
* **Trend Identification:**
* In an uptrend, prices may consistently touch or "ride" the Upper Channel.
* In a downtrend, prices may consistently touch or "ride" the Lower Channel.
* **Volatility:** The width of the channel can give an indication of volatility. Wider channels suggest higher volatility over the lookback period.
* **"Turtle Trading" Strategy:** Price Channels (like Donchian Channels) were famously used in the "Turtle Trading" system, where breakouts from the channel were used as entry signals.
## Limitations and Considerations
* **Lag:** Like all indicators based on lookback periods, there's an inherent lag. The channel reflects past price action.
* **Whipsaws:** In choppy, non-trending markets, breakouts can be false, leading to whipsaws.
* **Parameter Choice:** The `Length` parameter is crucial. A length too short may generate many false signals, while one too long may miss timely entries.
* **Not a Standalone System:** Best used in conjunction with other indicators (e.g., volume, trend indicators) or price action analysis for confirmation.
## References
* Donchian, R. D. (Various). (Conceptual basis for channel breakouts).
* Faith, C. (2007). *Way of the Turtle*. McGraw-Hill. (Describes trading systems using similar channels).
+64
View File
@@ -0,0 +1,64 @@
// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Price Channel (PCHANNEL)", "PCHANNEL", overlay=true)
//@function Calculates Price Channel
//@param length_param Lookback period for determining the highest high and lowest low
//@returns tuple [upperChannel, middleChannel, lowerChannel]
//@optimized Uses monotonic deque for O(1) amortized complexity per bar
pchannel(simple int length_param) =>
if length_param <= 0
runtime.error("Length must be greater than 0")
var deque_hi = array.new_int(0)
var src_buffer_hi = array.new_float(0, na)
var int current_index_hi = 0
var deque_lo = array.new_int(0)
var src_buffer_lo = array.new_float(0, na)
var int current_index_lo = 0
if array.size(src_buffer_hi) != length_param
src_buffer_hi := array.new_float(length_param, na)
current_index_hi := 0
array.clear(deque_hi)
src_buffer_lo := array.new_float(length_param, na)
current_index_lo := 0
array.clear(deque_lo)
float cv_hi = nz(high)
array.set(src_buffer_hi, current_index_hi, cv_hi)
float cv_lo = nz(low)
array.set(src_buffer_lo, current_index_lo, cv_lo)
while array.size(deque_hi) > 0 and array.get(deque_hi, 0) <= bar_index - length_param
array.shift(deque_hi)
while array.size(deque_lo) > 0 and array.get(deque_lo, 0) <= bar_index - length_param
array.shift(deque_lo)
while array.size(deque_hi) > 0
if array.get(src_buffer_hi, array.get(deque_hi, array.size(deque_hi) - 1) % length_param) <= cv_hi
array.pop(deque_hi)
else
break
array.push(deque_hi, bar_index)
while array.size(deque_lo) > 0
if array.get(src_buffer_lo, array.get(deque_lo, array.size(deque_lo) - 1) % length_param) >= cv_lo
array.pop(deque_lo)
else
break
array.push(deque_lo, bar_index)
float highestHigh = array.get(src_buffer_hi, array.get(deque_hi, 0) % length_param)
current_index_hi := (current_index_hi + 1) % length_param
float lowestLow = array.get(src_buffer_lo, array.get(deque_lo, 0) % length_param)
current_index_lo := (current_index_lo + 1) % length_param
[highestHigh, (highestHigh + lowestLow) / 2.0, lowestLow]
// ---------- Main loop ----------
// Inputs
i_length = input.int(20, "Length", minval=1)
// Calculation
[upperCh, middleCh, lowerCh] = pchannel(i_length)
// Plot
plot(middleCh, "Middle Channel", color=color.yellow, linewidth=2)
p1 = plot(upperCh, "Upper Channel", color=color.yellow, linewidth=2)
p2 = plot(lowerCh, "Lower Channel", color=color.yellow, linewidth=2)
fill(p1, p2, color=color.new(color.blue, 90), title="Band Fill")