OPEN-SOURCE SCRIPT

GMO (Gyroscopic Momentum Oscillator)

Atualizado
GMO

Overview
This indicator fuses multiple advanced concepts to give traders a comprehensive view of market momentum, volatility, and potential turning points. It leverages the Gyroscopic Momentum Oscillator (GMO) foundation and layers on IQR-based bands, dynamic ATR-adjusted OB/OS levels, torque filtering, and divergence detection. The outcome is a versatile tool that can assist in identifying both short-term squeezes and long-term reversal zones while detecting subtle shifts in momentum acceleration.

Key Components:

Gyroscopic Momentum Oscillator (GMO) – A physics-inspired metric capturing trend stability and momentum by treating price dynamics as “angle,” “angular velocity,” and “inertia.”
IQR Bands – Highlight statistically typical oscillation ranges, providing insight into short-term squeezes and potential near-term trend shifts.

ATR-Adjusted OB/OS Levels – Dynamic thresholds for overbought/oversold conditions, adapting to volatility, aiding in identifying long-term potential reversal zones.
Torque Filtering & Scaling – Smooths and thresholds torque (the rate of change of momentum) and visually scales it for clarity, indicating sudden force changes that may precede volatility adjustments.

Divergence Detection – Highlights potential reversal cues by comparing oscillator swings against price swings, revealing regular and hidden bullish/bearish divergences.
Conceptual Insights
IQR Bands (Short-Term Squeeze & Trend Direction):

Short-Term Momentum and Squeeze: The IQR (Interquartile Range) bands show where the oscillator tends to “live” statistically. When the GMO line hovers within compressed IQR bands, it can signal a momentum squeeze phase. Exiting these tight ranges often correlates with short-term breakout opportunities.

Trend Reversals: If the oscillator pushes beyond these IQR ranges, it may indicate an emerging short-term trend change. Traders can watch for GMO escaping the IQR “comfort zone” to anticipate a new directional move.
Dynamic OB/OS Levels (Long-Term Reversal Zones):

ATR-Based Adaptive Thresholds: Instead of static overbought/oversold lines, this tool uses ATR to adjust OB/OS boundaries. In calm markets, these lines remain closer to ±90. As volatility rises, they approach ±100, reflecting greater permissible swings.

Long-Term Trend Reversal Potential: If GMO hits these dynamically adjusted OB/OS extremes, it suggests conditions ripe for possible long-term trend reversals. Traders seeking major inflection points may find these adaptive levels more reliable than fixed thresholds.
Torque (Sudden Force & Directional Shifts):

Momentum Acceleration Insight: Torque represents the second derivative of momentum, highlighting how quickly momentum is changing. High positive torque suggests a rapidly strengthening bullish force, while high negative torque warns of sudden bearish pressure.
Early Warning & Stability/Volatility Adjustments: By monitoring torque spikes, traders can anticipate momentum shifts before price fully confirms them. This can signal imminent changes in stability or increased volatility phases.

Indicator Parameters and Usage
GMO-Related Inputs:

lenPivot (Default 100): Length for calculating the pivot line (slow market axis).
lenSmoothAngle (Default 200): Smooths the angle measure, reducing noise.
lenATR (Default 14): ATR period for scaling factor, linking price changes to volatility.
useVolatility (Default true): If true, volatility (ATR) influences inertia, adjusting momentum calculations.
useVolume (Default false): If true, volume affects inertia, adding a liquidity dimension to momentum.
lenVolSmoothing (Default 50): Smooths volume calculations if useVolume is enabled.
lenMomentumSmooth (Default 20): EMA smoothing of GMO for a cleaner oscillator line.
normalizeRange (Default true): Normalizes GMO to a fixed [-100, 100] range for consistent interpretation.
lenNorm (Default 100): Length for normalization window, ensuring GMO’s scale adapts to recent extremes.
IQR Bands Settings:

iqrLength (Default 14): Period to compute the oscillator’s statistical IQR.
iqrMult (Default 1.5): Multiplier to define the upper and lower IQR-based bands.
ATR-Adjusted OB/OS Settings:

baseOBLevel (Fixed at 90) and baseOSLevel (Fixed at 90): Base lines for OB/OS.
atrPeriodForOBOS (Default 50): ATR length for adjusting OB/OS thresholds dynamically.
atrScaling (Default 0.2): Controls how strongly volatility affects OB/OS lines.
Torque Filtering & Visualization:

torqueSmoothLength (Default 10): EMA length to smooth raw torque values.
atrPeriodForTorque (Default 14): ATR period to determine torque threshold.
atrTorqueScaling (Default 0.5): Scales ATR for determining torque’s “significant” threshold.
torqueScaleFactor (Default 10.0): Multiplies the torque values for better visual prominence on the chart.
Divergence Inputs:

showDivergences (Default true): Toggles divergence signals.
lbR, lbL (Defaults 5): Pivot lookback periods to identify swing highs and lows.
rangeUpper, rangeLower: Bar constraints to validate potential divergences.
plotBull, plotHiddenBull, plotBear, plotHiddenBear: Toggles for each divergence type.

Visual Elements on the Chart
GMO Line (Blue) & Zero Line (Gray):
GMO line oscillates around zero. Positive territory hints bullish momentum, negative suggests bearish.

IQR Bands (Teal Lines & Yellow Fill):
Upper/lower bands form a statistical “normal range” for GMO. The median line (purple) provides a central reference. Contraction near these bands indicates a short-term squeeze, expansions beyond them can signal emerging short-term trend changes.

Dynamic OB/OS (Red & Green Lines):
Red line near +90 to +100: Overbought zone (dynamic).
Green line near -90 to -100: Oversold zone (dynamic).
Movement into these zones may mark significant, longer-term reversal potential.

Torque Histogram (Colored Bars):
Plotted below GMO. Green bars = torque above positive threshold (bullish acceleration).
Red bars = torque below negative threshold (bearish acceleration).
Gray bars = neutral range.
This provides early warnings of momentum shifts before price responds fully.

Precession (Orange Line):
Scaled for visibility, adds context to long-term angular shifts in the oscillator.

Divergence Signals (Shapes):
Circles and offset lines highlight regular or hidden bullish/bearish divergences, offering potential reversal signals.

Practical Interpretation & Strategy
Short-Term Opportunities (IQR Focus):
If GMO compresses within IQR bands, the market might be “winding up.” A break above/below these bands can signal a short-term trade opportunity.

Long-Term Reversal Zones (Dynamic OB/OS):
When GMO approaches these dynamically adjusted extremes, conditions may be ripe for a major trend shift. This is particularly useful for swing or position traders looking for significant turnarounds.

Monitoring Torque for Acceleration Cues:
Torque spikes can precede price action, serving as an early catalyst signal. If torque turns strongly positive, anticipate bullish acceleration; strongly negative torque may warn of upcoming bearish pressure.

Confirm with Divergences:
Divergences between price and GMO reinforce potential reversal or continuation signals identified by IQR, OB/OS, or torque. Use them to increase confidence in setups.

Tips and Best Practices
Combine with Price & Volume Action:
While the indicator is powerful, always confirm signals with actual price structure, volume patterns, or other trend-following tools.

Adjust Lengths & Periods as Needed:
Shorter lengths = more responsiveness but more noise. Longer lengths = smoother signals but greater lag. Tune parameters to match your trading style and timeframe.

Use ATR and Volume Settings Wisely:
If markets are highly volatile, consider useVolatility to refine momentum readings. If liquidity is key, enable useVolume.

Scaling Torque:
If torque bars are hard to read, increase torqueScaleFactor further. The scaling doesn’t affect logic—only visibility.

Conclusion
The “GMO + IQR Bands + ATR-Adjusted OB/OS + Torque Filtering (Scaled)” indicator presents a holistic framework for understanding market momentum across multiple timescales and conditions. By interpreting short-term squeezes via IQR bands, long-term reversal zones via adaptive OB/OS, and subtle acceleration changes through torque, traders can gain advanced insights into when to anticipate breakouts, manage risk around potential reversals, and fine-tune timing for entries and exits.

This integrated approach helps navigate complex market dynamics, making it a valuable addition to any technical analysis toolkit.
Notas de Lançamento
Key Updates to GMO Indicator
Added Gyroscopic Inputs:

Mass (mass): Proxy for trading volume.
Radius (radius): Proxy for market volatility.
Gyro Influence Multiplier (gyro_multiplier): Controls the extent of gyroscopic adjustments.
Implemented Gyroscopic Calculations:

Functions Introduced:
gyro_precession: Calculates precession rate based on angular velocity, mass, and radius.
gyro_angular_momentum: Computes angular momentum influenced by mass, angular velocity, and radius.
Replaced pow(radius, 2) with radius * radius: Enhanced performance and resolved the pow function error.
Integrated Gyroscopic Adjustments into GMO:

Adjusted Inertia: Modified original inertia by adding smoothed gyroscopic adjustments multiplied by the gyro multiplier.
Recalculated Angular Momentum & Torque: Incorporated gyroscopic logic to make the oscillator more responsive to dynamic market conditions.
Enhanced Visualization:

Torque Histogram Coloring:
Green: When torque exceeds the positive threshold.
Red: When torque exceeds the negative threshold.
Gray: When torque is within thresholds.
Precession Plot: Added a scaled precession rate visualization for additional market insights.
Code Optimizations:

Namespace Corrections: Prefixed mathematical functions with math. where necessary.
Efficiency Improvements: Utilized direct multiplication for squaring operations instead of math.pow for better performance.
Maintained Original Functionalities:

IQR Bands, ATR-Adjusted Overbought/Oversold Levels, and Divergence Logic: These core features remain intact and are now enhanced with gyroscopic dynamics.
Centered OscillatorsCyclesOscillators

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal