MA Envelope Strategy Optimization for TradingView
Optimize MA Envelope strategy parameters on TradingView with Pineify grid search. Test period, bandwidth, and MA type across thousands of combos.
Add to Chrome FreeBuilding a MA Envelope Strategy
A Moving Average Envelope consists of a central moving average with upper and lower bands plotted at a fixed percentage above and below. The strategy generates buy signals when price touches or crosses below the lower band, and sell signals when it touches or crosses above the upper band. This assumes price will revert toward the mean, making it a mean-reversion strategy by nature.
The key parameters that control MA Envelope behavior are: the MA period (how many bars the moving average looks back), the envelope percentage (bandwidth), the type of moving average (SMA, EMA, or WMA), and whether entry triggers on a touch of the band or requires a full close beyond it. Each choice shifts the trade frequency and profit profile significantly.
Optimizable Parameters
| Parameter | Description | Typical Range |
|---|---|---|
| MA Period | Number of bars used in the moving average calculation | 10 - 50 (step 5) |
| Envelope % | Percentage distance from MA to upper and lower bands | 1% - 10% (step 0.5%) |
| MA Type | Type of moving average for the centerline | SMA, EMA, WMA |
| Entry on Touch | Whether to enter when price touches the band or wait for close beyond it | true / false |
Real Optimization Run
I ran a grid search on MA Envelope with period 10-50 step 5, envelope 1-5% step 0.5%, and all three MA types on EURUSD hourly. That is 9 x 9 x 3 = 243 combinations when entry on touch was true, plus another 243 when false : 486 total. The optimization finished in roughly 8 minutes. The best setup used EMA period 20 with a 2.5% envelope and entry on touch, delivering a 1.9 Sharpe ratio over 2 years. I was surprised that widening the bands past 3.5% produced almost no additional trades. Not sure if these settings transfer to crypto markets, the mean reversion behavior is very different there.
Frequently Asked Questions
Related Strategy Optimizations
Start Optimizing Your MA Envelope Strategy
Download Pineify Supercharged for free and run your first grid search optimization in minutes.
Add to Chrome Free