MA Envelope Optimization: Define the Band and the Trade

Define percentage envelope bands, mean-reversion or breakout rules, and order timing before comparing a TradingView strategy parameter grid.

View Chrome Extension

Building a Strategy with MA Envelope

A percentage envelope places bands above and below a moving average. With a basis of 100 and a distance of 2%, the upper band is 102 and the lower band is 98. That is 2% on each side, not a total width of 2%. Unlike an ATR or standard-deviation band, this distance does not automatically expand when those volatility measures rise.

The bands alone do not specify a trade. A mean-reversion rule might buy after a lower-band excursion and return inside; a continuation rule might buy an upper-band breakout. Those are different hypotheses. Choose one, define its exit and position sizing, and keep the other as a separate experiment. TradingView’s built-in Envelope offers SMA or EMA as the basis. WMA is a possible custom-strategy choice only if the script implements it.

Order timing also needs a definition. A limit order placed before a touch, an order generated after observing a bar’s low, and a close-confirmed signal do not imply the same fill price. A chart showing that price touched a band does not establish that a live order was resting there. Keep the band calculation, signal timestamp and order model consistent when comparing configurations.

Optimizable Parameters

MA Envelope strategy inputs and illustrative test values
ParameterDescriptionExample Test Values
MA periodNumber of chart bars in the chosen moving average10–50, step 5: 9 choices
Band distancePercentage on each side of the basis; confirm input units1–5%, step 0.5: 9 choices
Basis calculationSMA and EMA; include WMA only if implemented in the strategySMA / EMA / custom WMA: 3 choices
Entry modelTwo explicitly implemented order/signal rules, with fills inspected separatelyPreplaced limit / close-confirmed: 2 choices

Optimization Example and Test Design

Hypothetical grid: 9 periods × 9 distances × 3 basis calculations × 2 entry models = 486 configurations. If the strategy offers only SMA and EMA, the same design has 324. These counts describe candidate tests, not completed research or a profitable setting. Hold the symbol, dates, source price, exits and costs fixed. Start by inspecting one trade from each entry model: verify when its band value was known, when the order was created and the price used for the fill. Retain a baseline and select candidates using a training interval; evaluate the unchanged candidates on a later interval. Record turnover and exposure as well as net results, since a wider band may simply leave the strategy out of the market more often.

Frequently Asked Questions

Start Optimizing Your MA Envelope Strategy

Install the extension, sign in and check your plan access. Automated parameter optimization requires an Advanced plan or above.

View Chrome Extension