Files
QuanTAlib/lib/channels/maenv/maenv.md
T
Miha Kralj d493bfd42f 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.
2025-12-31 23:39:47 -08:00

46 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Moving Average Envelope
Moving Average Envelope consists of three lines: a moving average in the middle and two lines plotted at a fixed percentage above and below it. The envelope provides a simple way to identify potential support and resistance levels based on a percentage deviation from the average price.
## Calculation
```
Middle = MA(Source, Length)
Upper = Middle + (Middle × Percentage/100)
Lower = Middle - (Middle × Percentage/100)
```
Where:
* MA = Moving Average (can be SMA, EMA, or WMA)
* Source = Price series (typically close price)
* Length = Lookback period for moving average
* Percentage = Fixed percentage for band width
## Parameters
* Source (default: close) - Price series used for the moving average
* Length (default: 20) - Period used for moving average calculation
* Percentage (default: 1.0) - Fixed percentage distance from MA to bands
* MA Type (default: 1) - Moving average type: 0:SMA, 1:EMA, or 2:WMA
## Interpretation
* The middle line shows the average price trend
* Upper and lower bands create a channel based on fixed percentage
* Price reaching the bands may indicate overbought/oversold conditions
* Unlike volatility-based bands, envelope width changes proportionally with price
* Band penetration may signal potential trend reversals
* Works best in trending markets with consistent volatility
## Implementation
The implementation includes:
* Choice of three moving average types (SMA, EMA, WMA)
* Optimized calculations for each MA type
* Circular buffer for efficient SMA calculation
* Alpha smoothing for EMA
* Linear weighting for WMA
* Proper handling of NA values
* Input validation
* Percentage-based band width calculation