OPEN-SOURCE SCRIPT

Adaptive Regime Compass MovingAverage Suite

100
Summary in one paragraph
Regime Compass Adaptive MA Suite is a three speed adaptive moving average indicator for liquid markets on intraday through daily charts. It helps you act only when price position, MA stack structure, reliability, and higher timeframe context align. It is original because it fuses robust outlier handling with efficiency driven adaptive smoothing, then compresses multi timeframe confirmation into a single compact panel plus directional reliability shading.

Scope and intent
• Markets. Major FX pairs, index futures, large cap equities, liquid crypto, and liquid commodities
• Timeframes. One minute through daily
• Default demo used in the publication.SPY 1h
• Purpose. Provide a practical trend context layer that adapts to regime and reduces false confidence during chop by exposing a reliability score and multi timeframe agreement
• Limits. This is an indicator. It does not place orders and does not simulate fills

Originality and usefulness
This is not a mashup of standard MAs. It is a single adaptive engine expressed at three speeds, plus a reliability model and a multi timeframe state panel.
• Unique concept or fusion. Robust input conditioning plus efficiency ratio driven adaptive alpha plus a reliability score that requires both structure and strength, projected across three higher timeframes with a consensus read
• What failure mode it addresses. Single bar spikes that poison classic smoothers, and false trend impressions during low efficiency chop where fixed length MAs keep crossing
• Testability. All behaviors are controlled in Inputs and echoed in the table so users can see why the state is bullish, bearish, or mixed and tune accordingly
• Portable yardstick. Efficiency ratio is dimensionless, so it generalizes across symbols and tick sizes. Slope strength is normalized by recent average absolute slope to reduce symbol dependence

Method overview in plain language

Base measures
Return basis. The engine measures directionality with an efficiency ratio, defined as absolute net change over a window divided by the sum of absolute bar to bar changes over the same window. Values closer to 1 indicate directional movement. Values closer to 0 indicate noise.
Range basis. Optional robust clipping uses a rolling mean and a scaled mean absolute deviation of price around that mean to define a dynamic clamp band for extreme bars.

Components
• Robust Clip. Optional step that clamps extreme deviations of the input series so single spikes do not disproportionately shift the MA state. Use it on wick heavy markets or news driven sessions. Disable it if you want raw sensitivity.
• Adaptive Alpha Core. The smoothing rate adapts between a fast and slow anchor using the efficiency ratio. In directional regimes the MA accelerates. In noisy regimes it slows down.
• Base Length Shaping. A second light smoothing stage ties each line to its fast, medium, or slow horizon so the trio remains coherent instead of behaving like three unrelated formulas.
• Zero Lag Assist. Optional phase compensation that slightly pulls the line toward its recent direction to reduce lag. It is strongest on the fast line and tapered on medium and slow. Disable it if you prefer maximum stability in chop.
• Reliability Score. A composite confidence estimate built from medium efficiency, MA stack coherence, and normalized medium slope strength. It is designed as a gating variable, not as a prediction.

Fusion rule
The three lines are produced by the same adaptive engine with different base lengths. The adaptive alpha uses the efficiency ratio to interpolate between the fast and slow anchors, then squares the result to damp small changes, similar in spirit to classic adaptive averages but implemented as a coherent three speed suite. Reliability is a weighted composite of:
• medium efficiency as the directionality signal
• a stack coherence score that is true when Fast is above Medium and Medium is above Slow, or the symmetric bearish condition
• medium slope strength normalized by recent average absolute slope

Signal rule
This script does not print buy or sell markers. It provides context states.
• Bullish structure is present when Fast is above Medium and Medium is above Slow
• Bearish structure is present when Fast is below Medium and Medium is below Slow
• Reliable regime shading is shown only when reliability is at or above the threshold and structure is consistently bullish or bearish
• Higher timeframe Trend in the table is Up when higher timeframe close is above its higher timeframe Medium and the higher timeframe Medium slope is positive. Down is the symmetric condition. Otherwise it is Neutral

What you will see on the chart
• Three adaptive MA lines: Compass Fast, Compass Medium, Compass Slow
• Optional line coloring: green when close is above the line, red when close is below
• Optional background shading: green for reliable bullish structure, red for reliable bearish structure
• Compact higher timeframe panel in the top right

Table fields and quick reading guide
Table columns use short labels.
• TF. The timeframe used for the row
• TREND. Up, Down, or Neutral on that higher timeframe using close versus Medium plus Medium slope sign
• C VS MED. Whether the higher timeframe close is above or below its higher timeframe Medium
• STACK. Two relationships shown together: F>M or F<M and M>S or M<S. Green means both are bullish, red means both are bearish, gray means mixed
• REL. Reliability score for that timeframe. Values above the threshold are shown as stronger context
• C VS AVG. In the ALL row only, compares current chart close to the average of the three higher timeframe Medium values
Reading tip. When TREND agrees across at least two of the three higher timeframes, STACK is coherent, and REL is above the threshold, the MA context is usually cleaner. Mixed STACK with low REL often indicates chop risk.

Inputs with guidance

Setup
• Source. Price input used by the engine. Close is default
• Fast Length, Medium Length, Slow Length. Typical ranges: Fast 8 to 21, Medium 21 to 55, Slow 55 to 144. Larger values increase stability and lag. Smaller values increase responsiveness
• Panel TF 1, TF 2, TF 3. Typical sets: 60, 240, D for intraday. 240, D, W for swing

Logic
• Efficiency Length. Typical range 20 to 60. Raising it slows adaptation and reduces noise sensitivity. Lowering it increases responsiveness and whipsaw risk
• Alpha Fast Anchor. Typical range 1 to 5. Lower is faster
• Alpha Slow Anchor. Typical range 20 to 60. Higher is smoother in chop

Filters
• Robust Clip. Enable for wick heavy or spiky markets. Disable for raw sensitivity
• Clip Length. Typical range 20 to 80. Higher is more conservative
• Clip Strength. Typical range 2.0 to 4.0. Lower clips more aggressively
• Zero Lag Assist. Enable if you want quicker reaction in trend. Disable if you want less overshoot risk
• Zero Lag Strength. Typical range 0.3 to 0.8. Higher reduces lag but can overshoot in mixed regimes
• Reliability Threshold. Typical range 0.50 to 0.70. Higher means fewer, stricter reliable regimes

UI
• Color By Close Position. Green above, red below for each line
• Directional Reliable Background. Background shading only when reliable and structurally coherent
• HTF Panel. Shows three timeframe context and a consensus row

Usage recipes

Intraday trend focus
• Panel TFs: 60, 240, D
• Robust Clip: On
• Zero Lag Assist: On, strength 0.5 to 0.7
• Reliability Threshold: 0.60 to 0.70
• Fast, Medium, Slow: 14, 34, 89

Intraday mean reversion focus
• Panel TFs: 60, 240, D
• Robust Clip: On
• Zero Lag Assist: Off or strength 0.2 to 0.4
• Efficiency Length: 34 to 55
• Reliability Threshold: 0.55 to 0.65
• Use the table to avoid fading when higher timeframe TREND is aligned and REL is high

Swing continuation
• Panel TFs: 240, D, W
• Robust Clip: Optional, often On for crypto
• Zero Lag Assist: Low or Off
• Fast, Medium, Slow: 21, 55, 144
• Reliability Threshold: 0.60 to 0.70

Realism and responsible publication
• No performance claims. Past results never guarantee future outcomes
• No certainty about the future
• Intrabar motion reminder. Table values, line colors, and background can update while a bar forms and settle on close
• Test on historical data and in simulation before any live use

Honest limitations and failure modes
• Economic releases and thin liquidity can create moves that bypass smoothing assumptions, even with clipping
• Gap heavy symbols can produce abrupt state changes. Robust Clip may reduce spike impact but cannot remove structural gaps
• Very quiet regimes can reduce contrast in reliability. Consider longer efficiency windows or a higher timeframe panel set
• Zero Lag Assist can overshoot in mixed regimes. Reduce strength or disable it when chop dominates
• Higher timeframe values update according to the higher timeframe bar. Until that bar closes, the HTF row is provisional

Open source reuse and credits
• Reuse. None from other public indicator scripts
• Public domain building blocks. Uses well known concepts such as efficiency ratio adaptive smoothing and standard smoothing constants. The implementation, three speed coherence design, reliability model, and table layout are original in this script

Legal
Education and research only. Not investment advice. You are responsible for your decisions. Test on historical data and in simulation before any live use. Use realistic costs when evaluating any trading approach.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.