Understanding the Envelope Indicator
Introduction
The Envelope indicator, also known as the Simple Moving Average Envelope, is a tool used in technical analysis to identify potential buy and sell signals. It consists of moving averages calculated from the underlying price, shifted up and down by a fixed percentage. This indicator is particularly significant in technical analysis as it helps traders identify trends and potential reversals in the market.
Origins
The Envelope indicator is a product of the evolution of technical analysis tools and has not been attributed to any particular inventor. It was developed as a means to better understand market trends and to identify potential points of reversal. Over time, it has become a staple in the toolkit of many traders, owing to its simplicity and effectiveness.
Mathematical Construction
This indicator is constructed using a simple moving average and a fixed percentage that creates an upper and lower band. The formulas used to calculate these boundaries are as follows:
Top Envelope: MATE = MA * ((100 + PERCENT) / 100)
which can also be shown as:
\text{{MATE}} = MA \times \left( \frac{{100 + \text{{PERCENT}}}}{{100}} \right)
Bottom Envelope: MABE = MA * ((100 – PERCENT) / 100)
which can also be shown as:
\text{{MABE}} = MA \times \left( \frac{{100 - \text{{PERCENT}}}}{{100}} \right)
Here, MA represents the moving average, and PERCENT represents the fixed percentage by which the moving average is shifted up and down to create the envelope.
These formulas create a band around the price action, and when prices rise above the upper band or fall below the lower band, a change in direction may occur. It’s important to note that the moving averages used in this indicator will always lag behind the actual prices, so they are used for trend identification and following, not for prediction.
Purpose and Design
It is designed to measure price volatility and identify potential trend reversals. It does this by creating a ‘moving envelope’ around the price action. This envelope consists of two bands – an upper and a lower band – which are calculated by shifting a simple moving average up and down by a fixed percentage.
The purpose of the Envelope indicator is twofold. Firstly, it helps traders identify the overall trend of the market. When the market consistently ranges between the moving average and the envelope, the trend is considered intact. Secondly, it can signal potential reversals. When prices rise above the upper band or fall below the lower band, a change in direction may occur after a small reversal from the opposite direction.
Itr stands out from other indicators due to its simplicity and effectiveness in trend identification and reversal prediction.
Interpreting Envelope Indicator Signals
Interpreting the signals from the indicator is pretty straightforward. When the price of an asset rises above the upper band, it may be an indication that the asset is overbought, and a price reversal may be imminent. Conversely, when the price falls below the lower band, it may suggest that the asset is oversold, and a price increase may be on the horizon.
While simple ideas are often the best the Envelope indicator should not be relied upon in isolation. It’s most effective when used in conjunction with other technical analysis tools to confirm signals and reduce the likelihood of false positives. Here’s some other indicators you might consider combining them with:
- Bollinger Bands:
- Why: Bollinger Bands expand and contract based on volatility, providing additional insight into the market’s volatility. Combining Envelopes (which focus on fixed percentages) with Bollinger Bands (which adapt to volatility) can provide a more nuanced view of support and resistance levels.
- Stochastic Oscillator:
- Why: The Stochastic Oscillator measures momentum and can help identify overbought and oversold conditions. By pairing it with Envelopes, you can better align trading signals with underlying momentum trends.
- Fibonacci Retracement Levels:
- Why: Fibonacci retracement levels are often used to identify potential reversal points in the market. Combining these levels with Envelopes can offer a more precise identification of potential entry and exit points, aligning with both trend following and reversal patterns.
- Ichimoku Cloud:
- Why: The Ichimoku Cloud offers a comprehensive view of the market’s trend, momentum, and support and resistance levels. Combining the Envelope indicator with the Ichimoku Cloud could provide a multifaceted approach to trend analysis, offering both short-term and long-term perspectives.
- On-Balance Volume (OBV):
- Why: OBV is a momentum indicator that uses volume to predict price changes. Combining OBV with Envelopes can help confirm price trends and signals by aligning them with underlying volume trends, adding a volume dimension to the analysis.
- Average True Range (ATR):
- Why: ATR measures market volatility, and combining it with Envelopes can help dynamically adjust the envelope percentage based on current market volatility. This can make the Envelopes more adaptive to changing market conditions.
- Chaos Theory Indicators (e.g., Fractals, Alligator):
- Why: Chaos Theory Indicators attempt to find order in seemingly random market patterns. Utilizing these indicators with Envelopes may provide a unique perspective on market structure and potential trend reversals.
- Adaptive Moving Averages (e.g., Kaufman’s Adaptive Moving Average):
- Why: Unlike Simple Moving Averages, Adaptive Moving Averages change sensitivity based on market volatility. Pairing them with Envelopes can create a more flexible and responsive trend-following system.
These combinations aim to enhance the functionality of the Simple Moving Average Envelope by adding different dimensions such as momentum, volatility, volume, and adaptiveness. By integrating various aspects of market behavior, traders can construct a more comprehensive and robust trading strategy. If experimenting, then test these combinations on historical data or a demo account before applying them to a live trading environment, as different markets and time frames may require adjustments to parameters and strategies. You should also incorporate fundamental considerations into your risk management and not only rely on technical analysis.
Pros and Cons
As with other tools used in technical analysis, the Envelope indicator has its strengths and weaknesses.
One of the main advantages of it is its simplicity. It’s easy to understand and use, even for novice traders. It’s also quite versatile, providing valuable information about market trends and potential reversals.
However, it also comes with some limitations. One potential pitfall is that it can produce false signals during periods of high market volatility. Additionally, it’s a lagging indicator, meaning it follows the price action and does not predict future movements.
Coding the Envelope Indicator in Popular Trading Languages
While you can find this indicator in many trading software packages, coding it yourself can be a rewarding exercise, helping you understand its inner workings and allowing for customization. Here, we’ll outline how to code the moving average envelope in Python and R, two popular languages in the trading world.
Python:
In Python, we can use the pandas library to calculate the moving average, and then create the upper and lower bands by adding and subtracting a fixed percentage.
import pandas as pd
def envelope_indicator(data, n, pct):
# Calculate the moving average
MA = data['Close'].rolling(window=n).mean()
# Calculate the upper Envelope as MA * (100 + PERCENT) / 100
data['Upper_Envelope'] = MA * (1 + pct/100)
# Calculate the lower Envelope as MA * (100 - PERCENT) / 100
data['Lower_Envelope'] = MA * (1 - pct/100)
return data
If you want to play around with this and see it plotted on a chart, you can use the free software VSCode from Microsoft and create a .py file then run it. Remember to follow the instructions in VSCode to install Python and any modules you see imported at the top on the file, then press play in the top right else by right-clicking in the file and selecting “Run Python File in Terminal”.
The code for the .py file:
import pandas as pd
import yfinance as yf
import matplotlib.pyplot as plt
def envelope_indicator(data, n, pct):
# Calculate the moving average
MA = data['Close'].rolling(window=n).mean()
# Calculate the upper and lower Envelopes
data['Upper_Envelope'] = MA * (1 + pct/100)
data['Lower_Envelope'] = MA * (1 - pct/100)
return data
# Download Nvidia stock data
data = yf.download('NVDA', start='2022-01-01', end='2023-01-01')
# Apply the Envelope indicator
data = envelope_indicator(data, n=20, pct=20)
# Plot the data
plt.figure(figsize=(14,7))
plt.plot(data['Close'], label='Close Price', color='blue')
plt.plot(data['Upper_Envelope'], label='Upper Envelope', color='red')
plt.plot(data['Lower_Envelope'], label='Lower Envelope', color='green')
plt.title('Envelope Indicator for Nvidia')
plt.xlabel('Date')
plt.ylabel('Price')
plt.legend(loc='best')
plt.grid(True)
plt.show()
This code will create a plot with the closing price of Nvidia stock and the upper and lower Envelope bands. The n
parameter in the envelope_indicator
function call is the moving average period, and the pct
parameter is the percentage shift for the Envelope bands. You can adjust these parameters as needed.
To run this code in VSCode, remember you’ll need to have the pandas
, yfinance
, and matplotlib
libraries installed. If they’re not installed, you can install them using pip:
pip install pandas yfinance matplotlib
You should get a result something like this:
R:
In R, we can use the TTR package to calculate the moving average, and then create the upper and lower bands similarly. You need to have the necessary libraries installed in your R environment. If not, you can install them using install.packages(c('TTR', 'ggplot2', 'quantmod'))
# Load necessary libraries
library(TTR)
library(ggplot2)
library(quantmod)
# Envelope Indicator Function
envelope_indicator <- function(data, n, pct) {
# Calculate the moving average
MA <- SMA(data$Close, n=n)
# Calculate the upper and lower Envelopes
data$Upper_Envelope <- MA * (1 + pct/100)
data$Lower_Envelope <- MA * (1 - pct/100)
return(data)
}
# Download Nvidia stock data
getSymbols('NVDA', src = 'yahoo', from = '2022-01-01', to = '2023-01-01')
data <- data.frame(Date=index(NVDA), coredata(NVDA))
# Apply the Envelope indicator
data <- envelope_indicator(data, n=20, pct=20)
# Plot the data
ggplot(data, aes(x=Date)) +
geom_line(aes(y=Close, color='Close Price')) +
geom_line(aes(y=Upper_Envelope, color='Upper Envelope')) +
geom_line(aes(y=Lower_Envelope, color='Lower Envelope')) +
labs(title='Envelope Indicator for Nvidia',
x='Date',
y='Price',
color='Legend') +
theme_minimal()
You can expand on using these basic stepping stones as you see fit.
Practical Tips for Using the Moving Average Envelope in Trading
Here are some practical tips for using it effectively:
- Use in Conjunction with Other Indicators: The Envelope indicator works best when used alongside other technical analysis tools. This can help confirm signals and reduce the risk of false positives.
- Adjust the Parameters: The parameters (the moving average period and the percentage shift) can and should be adjusted to suit different trading styles and timeframes. As suggested in John J. Murphy’s “Technical Analysis of the Financial Markets,” shorter-term traders often use 3% envelopes around a simple 21-day moving average to identify when the short-term trend is overextended. For long-range analysis, some possible combinations include 5% envelopes around a 10-week average or a 10% envelope around a 40-week average. Experiment with different settings to find what works best for you.
- Beware of False Signals: During periods of high market volatility, it can produce false signals. Always consider the overall market conditions when interpreting signals.
- Use for Trend Identification: It is excellent for identifying the overall trend of the market. If the market consistently ranges between the moving average and the envelope, the trend is considered intact.
Key Takeaways
- Definition and Use: The Envelope indicator, also known as the Simple Moving Average Envelope, is a technical analysis tool used to identify market trends and potential reversals by creating bands around the price action.
- Mathematical Construction: It is constructed using a simple moving average (MA) and a fixed percentage (PERCENT) to create upper and lower bands. The formulas are: Top of Envelope = MA * ((100 + PERCENT) / 100) and Bottom of Envelope = MA * ((100 – PERCENT) / 100)
- Interpretation: The indicator signals overbought conditions when the price rises above the upper band, and oversold conditions when it falls below the lower band.
- Complementary Tools: It is most effective when used in conjunction with other technical analysis tools like Bollinger Bands, Stochastic Oscillator, Fibonacci Retracement Levels, and more.
- Coding Implementation: The post provides examples of how to code the moving average envelope in both Python and R, offering a hands-on approach to understanding its mechanics.
- Practical Tips: Using the Envelope indicator in conjunction with other indicators, adjusting its parameters to suit different trading styles, and being mindful of false signals during high volatility are essential practices for effective application.
- Pros and Cons: The its simplicity and effectiveness are its main advantages, while its potential for false signals during high volatility and its nature as a lagging indicator are limitations to be aware of.
- Versatility: Its flexibility in trend identification, reversal prediction, and adaptability with various other indicators makes it a valuable tool in the trader’s toolkit.
Further Reading
- “Technical Analysis of the Financial Markets” by John J. Murphy: This book provides an in-depth look at various technical analysis tools, including the Envelope indicator. In particular, refer to the section that discusses the use of percentage envelopes around moving averages to identify overextended trends (see Figures 9.8a-b).
- “Technical Analysis: The Complete Resource for Financial Market Technicians” Charles Kirkpatrick II & Julie Dahlquist (3rd Edition)
Leave a Reply