User guide
Forex Cipher’s guide to Adaptive Channel Trend: read the chart, understand the engine and configure the current script.
About the indicator
Adaptive Channel Trend is Forex Cipher’s open-source tool for reading bullish and bearish price regimes. It brings an adaptive average, volatility bands, completed price-channel levels and a trailing reference into one chart overlay.
The average reacts to directional efficiency. The bands allow room for price variation, while the completed channel contributes established highs and lows. These references determine a trail that tightens within a trend and resets when the regime changes.
Use the green/red candles and BUY/SELL labels to understand the active regime. They describe the indicator’s current state; they are not forecasts or performance results.
How it works
Each bar passes through five stages: measure directional efficiency, update the average, estimate the channel width, blend volatility with completed structure, and evaluate the trend trail. Display switches control chart layers without switching off these calculations.
- Measure efficiency over Efficiency length.
- Update the recursive average using the fast and slow endpoint rates.
- Build bands from exponentially smoothed residual energy and an ATR floor.
- Read channel extremes from the preceding completed calculation.
- Update the one-way trail and check for a regime change.
Directional efficiency
Efficiency compares the price change across the lookback with the sum of the smaller changes inside that period. A direct move scores higher than a path that repeatedly changes direction. The result stays between zero and one.
- Near 1: net progress accounts for much of the total movement.
- Near 0: accumulated movement is large compared with net progress.
- Efficiency length controls the measurement window.
fc_efficiency(series float values, simple int span) =>
float traveled = 0.0
for lag = 0 to span - 1
traveled += math.abs(nz(values[lag], values) - nz(values[lag + 1], values))
float distance = math.abs(values - nz(values[span], values))
traveled > 0 ? math.min(1.0, math.max(0.0, distance / traveled)) : 0.0The dashboard displays efficiency as a percentage. That percentage summarizes recent price movement; it does not represent signal success.
Adaptive moving average
The average is a recursive price baseline controlled by Fast response, Slow response and directional efficiency. The shorter response length defines the faster endpoint, even if the two inputs are entered in reverse order.
This engine squares each endpoint rate separately. It then uses squared efficiency to interpolate between those rates before updating the previous average. This is the response formula used by the current Forex Cipher implementation.
float fastRate = math.pow(2.0 / (math.min(rapid, steady) + 1), 2)
float slowRate = math.pow(2.0 / (math.max(rapid, steady) + 1), 2)
float response = slowRate + (fastRate - slowRate) * math.pow(efficiency, 2)
var float center = na
center := na(center[1]) ? price : center[1] + response * (price - center[1])Adaptive volatility bands
After updating the average, the engine squares the difference between the selected price and that average. An exponential moving average smooths this residual energy over Residual length.
The square root of that energy supplies a displacement estimate. Band multiplier scales it; Minimum band ATR provides a second, ATR-based distance. The larger distance becomes the radius of the adaptive bands.
The upper band is the average plus the radius, and the lower band is the average minus the radius. The optional cloud shows that space; the numerical band values also feed the trail calculation.
float energy = ta.ema(math.pow(price - center, 2), energyLength)
float volatility = math.max(nz(ta.atr(volatilityLength), ta.tr(true)), syminfo.mintick)
float radius = math.max(math.sqrt(math.max(energy, 0)) * radiusFactor, volatility * minimumRadius)
float upper = center + radius
float lower = center - radiusCompleted price channel
Completed channel length sets the window used to find the highest high and lowest low. The engine uses the preceding bar’s channel calculation, so the current bar does not redefine the structural reference it is being compared with.
A shorter window focuses on nearby extremes; a longer window includes more historical structure. The gray stepped lines display these levels separately from the adaptive bands.
float recentCeiling = ta.highest(high, structureLength)
float recentBase = ta.lowest(low, structureLength)
float ceiling = nz(recentCeiling[1], high)
float base = nz(recentBase[1], low)Efficiency-weighted defense
Structure influence scales the efficiency reading into a channel weight, capped at one. The rest of the weight belongs to the adaptive band. Low efficiency therefore favors band-based defense; higher efficiency allows completed structure to contribute more.
The bullish reference blends the lower band with the completed channel low. The bearish reference blends the upper band with the completed channel high. A Structure influence of zero leaves the defense entirely band-based.
float structuralShare = math.min(1.0, efficiency * structureScale)
float support = lower + structuralShare * (base - lower)
float resistance = upper + structuralShare * (ceiling - upper)Once the calculated weight reaches one, the completed channel supplies the full blended reference. The band remains visible if enabled, but its share of that reference becomes zero.
One-way adaptive trail
The trail retains the previous bar’s regime while it updates its defensive level. In a bullish regime it takes the higher of its inherited level and the new support reference. In a bearish regime it takes the lower of its inherited level and the resistance reference.
This makes the trail move in one direction within each regime. Once price crosses against that regime, the engine changes state and places the trail on the opposite side of price.
rail := priorBias == 1 ? math.max(inheritedRail, support) : math.min(inheritedRail, resistance)Reset distance ATR scales the volatility allowance after a reversal. The engine uses the larger of this allowance and the current band radius, then resumes its one-way update on subsequent bars.
BUY and SELL logic
BUY and SELL appear at regime transitions. The engine first updates the active trail, then compares the selected Price source with that level. Equality alone does not cause a reversal.
- BUY requires a previously bearish regime and price strictly above the updated trail.
- SELL requires a previously bullish regime and price strictly below the updated trail.
- The reversal resets the trail using the larger of its band radius and ATR-based allowance.
- During an uninterrupted regime, no new transition label is generated.
if priorBias == 1 and price < rail
bias := -1
rail := price + allowance
else if priorBias == -1 and price > rail
bias := 1
rail := price - allowance
bool buyEvent = bias == 1 and priorBias == -1
bool sellEvent = bias == -1 and priorBias == 1On an unfinished candle, price and the calculated trail can still change. Review the dashboard’s Signal status and your alert frequency before treating a displayed reversal as closed-bar information.
Visual feedback
The default palette is bright green for a bullish regime and red for a bearish regime. Candle coloring follows the regime rather than each candle’s open-to-close movement, so a falling candle can still be green.
Full candle colors draws the body, wick and border in the same regime color. The chart layers remain independently configurable in Display, and the BUY color and SELL color inputs set the palette.
- Adaptive Average: the responsive price baseline.
- Upper / Lower Adaptive Band: the limits surrounding that baseline.
- Adaptive Cloud: optional shading between the two bands.
- Upper / Lower Price Channel: established extremes shown as gray steps.
- BUY / SELL Trail: the active defense, with gaps between opposite regimes.
- BUY / SELL labels: transition events placed below or above the bar.
Hiding a layer only changes presentation. The average, channel and trail calculations continue, and alert conditions remain active even if BUY / SELL labels are hidden.
Data Window and dashboard
The downloadable script exposes four measurements in TradingView’s Data Window. These values show how the engine arrived at its current regime; they are not accuracy scores.
- Trend Efficiency: the normalized reading from 0 to 1.
- Structural Defense Weight: the channel share used in the blend.
- Band Distance ATR: the current radius divided by ATR.
- Trend State: 1 for bullish, −1 for bearish.
The dashboard includes regime, efficiency percentage, structure weight, trail buffer in ATR units, trend age, relative volatility and candle status. Trail buffer uses the absolute distance between the selected price and the active trail.
Trend age counts bars from the most recent reversal, or from the first loaded bar if none has occurred. Relative volatility divides ATR by its 50-bar simple average and shows Warming up until that comparison exists.
The website chart uses historical Gold candles with the default engine settings. The full dashboard and its Position and Text size controls are included in the downloadable Pine script.
Settings and controls
The table follows the input names and defaults in the current downloadable script. Code examples in this guide are excerpts of that script, not standalone indicators. The downloadable Pine script exposes each input, so you can adjust smoothing, structural sensitivity, volatility allowance and visual presentation for your chart.
| Control | Default | Purpose |
|---|---|---|
| Price source | Close | Used throughout efficiency, average and reversal calculations. |
| Efficiency length | 14 | Observation period for directional efficiency. |
| Fast response / Slow response | 2 / 30 | Fast and slow limits for the adaptive average’s response. |
| Residual length | 20 | Exponential smoothing period for squared residual energy. |
| Band multiplier | 2.0 | Multiplier applied to residual RMS distance. |
| Minimum band ATR | 0.7 | Minimum band distance as an ATR multiple. |
| Completed channel length | 22 | Lookback for completed structural highs and lows. |
| Structure influence | 1.25 | Rate at which efficiency increases structural-defense weight. |
| ATR length | 14 | Volatility period used for band floor and reversal reset. |
| Reset distance ATR | 1.5 | ATR multiplier for the initial trail after a reversal. |
| Average / bands / channel / trail | Shown | Independent display controls; calculations remain active. |
| Signal labels / candle coloring | On | Show BUY/SELL labels and full regime-colored candles. |
| BUY color / SELL color | Green / red | Default RGB(57, 255, 20) and RGB(255, 0, 0). |
| Dashboard | On · top right · small | Show or hide the panel, reposition it and adjust text size. |
Apply the indicator
- Open the Source code tab above and copy the complete Pine Script v6 code, or download the file.
- In TradingView, open Pine Editor, replace the editor contents with the full script, then Save and Add to chart. Keep the version directive on the first line.
- Select your symbol and timeframe, review the inputs, and choose which visual layers to display.
- For the new green/red defaults, remove any old indicator instance and add this version fresh; saved input settings can retain older colors.
- Enable the dashboard if needed and configure Buy Signal or Sell Signal alerts to suit your notification workflow.
The Vela preview on this page applies the same default mathematics to historical Gold data. Other platforms need a compatible Pine engine or a separate port; a Pine file cannot be installed directly as an MT4/MT5 indicator.
TradingView alerts
The script provides Buy Signal and Sell Signal alert conditions. Each uses the same regime-transition event as its matching chart label.
In TradingView’s alert dialog, select Adaptive Channel Trend and the required condition. Use Once Per Bar Close if your workflow needs a closed-bar event. A live-bar event can change before the bar finishes.
Alerts report indicator events. Order execution, position sizing and exits require a separate workflow.
What connects the model
Efficiency has two roles in this engine: it changes the average’s response and controls the share of completed structure in the defense. The band radius and one-way trail then turn those inputs into a single persistent regime.
- Average response uses squared endpoint rates and squared efficiency.
- Band width uses an EMA of squared residuals plus an ATR minimum.
- Completed structure contributes according to its efficiency-based weight.
- The trail tightens within a regime and resets on a reversal.
Intended use
Adaptive Channel Trend provides directional context and a moving structural reference. Use it to inspect the current regime, distinguish efficient movement from back-and-forth price action, and review where a regime transition occurred.
The same price-based calculation can run on Gold, forex, Bitcoin and other supported symbols. Different timeframes, feeds, settings and loaded history can produce different trails and labels.
- Read the regime from the trail and candle colors.
- Review BUY/SELL transitions alongside your own chart context.
- Compare efficiency and structure weight to understand the current defense.
- Inspect the distance to the trail without treating it as an order or forecast.
Limitations
The indicator describes a price regime; it does not establish a complete trading strategy or guarantee a profitable outcome. Historical labels show past state changes, not a verified win rate.
Repeated crossings are possible in sideways markets. Shorter response and channel lengths can react sooner but can also change state more frequently. Wider bands and longer lengths can require a larger move before a reversal.
Efficiency measures the route price already traveled. It is not a probability of the next move. The bands are modeled displacement boundaries rather than guaranteed support or resistance.
The trail does not submit a stop order to a broker. Live candles, broker feeds, available history and warm-up conditions can affect readings. Review the selected inputs and bar status when comparing charts.

