Skip to main content
On this page

Envelope Indicator: Percentage Bands and Testable Trading Rules

· 5 min read
Pineify Team
Pine Script and AI trading workflow research team

A moving-average envelope places bands a chosen percentage above and below a moving average. It measures distance from that average; touching a band does not by itself establish support, resistance or a reversal.

Envelope Indicator - TradingView Chart showing price action within trading bands

Calculate the bands​

For moving average M and percentage p:

  • Upper band = M × (1 + p / 100).
  • Lower band = M × (1 - p / 100).
  • Total width = 2 × M × p / 100, for a positive M.

For an illustrative average of $190 and a 5% envelope, the bands are $199.50 and $180.50. These numbers demonstrate the formula; they are not an observed AAPL trade.

The percentage distance is fixed, but the dollar width changes with the moving average. At a $100 basis, a 5% envelope spans $10; at a $200 basis, it spans $20. Calling its width constant without specifying percentage units is misleading.

A Bollinger-style band uses a standard-deviation term instead of a fixed percentage term. That difference does not establish that either method predicts reversals better. Both depend on the selected source and lookback.

Configure the correct Envelope indicator​

The Best Pine Script Generator

In TradingView, search the Indicators menu for Envelopes and inspect its settings. Record the source, length, percentage and moving-average choice so that comparisons use the same calculation.

Pineify's Envelope component exposes Source, Length, Percent and an Exponential switch. The current configuration defaults to close, length 20, percent 10 and SMA; enabling Exponential selects EMA. Defaults describe the product configuration, not tested optimal settings. This component is marked as a paid feature in the indicator catalog.

Creating envelope indicator in Pineify editor interface

Do not confuse it with a separately named EMA Envelope, which uses averages of high, low and close rather than a percentage offset. Verify the generated formula and output names before comparing charts.

Pineify generates a script from the configuration. Add that script to TradingView to inspect its chart values. To test trades, define entry and exit conditions in a strategy and use TradingView's broker emulator. Configuring an indicator does not itself run a backtest or prove a return.

Choose between two competing hypotheses​

A price move beyond an upper band can be interpreted as either an unusually large deviation to fade or a continuation signal to follow. The envelope alone does not decide which interpretation is appropriate.

HypothesisExample rule to specify before testingFailure to measure
Mean reversionA close below the lower band followed by a close back inside; entry on the next eligible executionPrice keeps falling or the average moves toward price without a profitable exit
Breakout continuationA confirmed close above the upper band; entry on the next eligible executionPrice returns inside the channel and repeated entries incur costs
Trend pullbackA separately defined trend condition plus a pullback toward the basisThe trend rule identifies a regime change too late

These are research designs, not recommendations or tested results. Each still needs a precise exit, position size, order type and invalidation rule. A historical touch of the band is not necessarily an executable fill at that price.

Select parameters without inventing a best setting​

A percentage that is rarely reached on one instrument may be crossed frequently on another. Estimate the distribution of percentage distance from the chosen moving average using a development sample, then test a small set of widths on later data. Keep the timeframe, source and session explicit.

Do not automatically double the width for crypto or assume an SMA length is suitable for all intraday charts. Changes in volatility alter the frequency of band touches even when the percentage stays fixed. Changing the width after seeing a loss also changes the strategy being evaluated.

An RSI, ADX or volume filter adds a condition and reduces or changes the trade sample. Compare the filtered rule with the unfiltered rule on the same data and costs. Its presence alone does not demonstrate better signal quality.

Evaluate expectancy rather than a win-rate headline​

An illustrative strategy winning 58% of trades with an average win of 1 unit and an average loss of 1.8 units has expectancy 0.58 × 1 - 0.42 × 1.8 = -0.176 units per trade before costs. This arithmetic is not a reported SPY backtest. Winners do not always need to be larger than losers, but win frequency and payoff size must jointly cover losses and costs.

For a reproducible study, save the script version, symbol/feed, dates, settings, commission, slippage and fill assumptions. Inspect individual trades and report trade count, net expectancy, drawdown, exposure and profit factor. Historical maximum drawdown does not cap future losses. A universal profit-factor threshold cannot establish reliability without sample size and test design.

Use TradingView's strategy documentation to check how the emulator processes your chosen orders. An out-of-sample interval and a forward observation period answer different questions from fitting the historical sample.

Does an envelope have constant width?
Its configured percentage distance is constant. Its price-unit width changes with the basis.
Is a lower-band touch a buy signal?
Only if a separately defined strategy uses it as one. Price can continue falling and the touch may not be an executable fill.
What settings are best for day trading?
No universal settings are established here. Evaluate the source, timeframe, length and percentage together with execution rules and costs.
Are Envelope and EMA Envelope the same Pineify component?
No. The percentage-based Envelope offers an SMA or EMA basis. The separately named EMA Envelope uses high, low and close averages.