OPEN-SOURCE SCRIPT
Glacial Momentum Index

Glacial Momentum Index (GMI) - Technical Documentation 🧊
Core Concept
The GMI is a momentum oscillator that measures sustained directional pressure in price movements. It combines velocity analysis with a for-loop scanning system to identify medium-term trends while filtering out noise and false breakouts.
Architecture
1. Velocity Index Calculation
velocity_index = (price - EMA) / ATR
Components:
Price Source: OHLC4 (average of open, high, low, close)
Velocity Basis: 40-period EMA of price
Normalization: ATR(24) makes the indicator adaptive to volatility
Purpose: Measures how far price has deviated from its moving average, scaled by current market volatility. This creates a normalized momentum reading that works across different market conditions.
2. For-Loop Momentum Score
The core innovation. Scans 5-55 bars (50-bar window) and counts directional consistency:
For each bar from 5 to 55 bars ago:
- If velocity_index > velocity_index: +1 point
- If velocity_index < velocity_index: -1 point
Final Score = (net points / total bars) × 100
Output: A percentage score from -100% to +100%
+100% = every bar shows upward momentum
-100% = every bar shows downward momentum
0% = equal distribution
Why 5-55 bars?
Start at 5 to ignore immediate noise
End at 55 to capture medium-term trends
Creates a 50-bar scanning window
3. Drift Layer
A 34-period slower velocity calculation providing macro context. Plotted as a white line scaled ×20 to match the velocity display range. This shows the underlying trend while the velocity index shows short-term moves.
Signal Logic
Entry Conditions
LONG:
Loop score > 28% (meaning 64%+ of scanned bars are trending up)
Velocity index > 0 (confirming current upward momentum)
SHORT:
Loop score < -25% (meaning 62%+ of scanned bars are trending down)
Velocity index < 0 (confirming current downward momentum)
State Persistence
Uses a state machine (signal_state: -1, 0, 1) that:
Enters long when both conditions meet
Stays long until short conditions trigger
No exit on neutral - holds position through consolidation
This prevents excessive trading during sideways markets.
Visual Elements
Histogram (Primary Signal)
Shows loop score as columns
Color: Cyan above long threshold, navy below short threshold, gray in between
Direct visualization of trend strength
Velocity Line (Thick, 4px)
Scaled ×20 to overlay on histogram
Color matches signal state (cyan=long, navy=short, gray=neutral)
Shows immediate momentum
Drift Line (White, 2px)
Scaled ×20 for consistency
Provides slower context
Helps identify when velocity is aligned with macro trend
Background Fill
Subtle tint (94% transparency)
Cyan during long state
Navy during short state
Instantly shows current position
Threshold Lines
Long: 28 (cyan dashed)
Short: -25 (navy dashed)
Zero: 0 (gray solid)
Signal Markers
Triangle up (cyan) on new long
Triangle down (navy) on new short
Only appear on state changes, not every bar
Why It Works for Crypto
ATR Normalization: Adapts to Bitcoin/Ethereum's variable volatility
Medium-Term Focus: 50-bar scan catches trends lasting days/weeks
State Persistence: Doesn't exit on minor pullbacks
Asymmetric Thresholds: 28/-25 reflects crypto's tendency to trend up stronger than down
Velocity Confirmation: Prevents entries when loop score is positive but price is actually falling
Parameter Tuning Guide
Velocity Period (40):
Lower (20-30) = more sensitive, faster signals
Higher (50-60) = smoother, fewer signals
Loop Window (5-55):
Wider window = catches longer trends
Narrower window = responds faster to changes
Long Threshold (28):
Lower (20-25) = more entries, potentially more noise
Higher (35-40) = fewer, higher-conviction entries
Short Threshold (-25):
Higher (-20 to -15) = more short entries
Lower (-30 to -35) = more selective shorts
Current Optimized Settings (BTC/ETH 4H-1D)
Velocity: 40 periods (catches medium-term momentum shifts)
Loop: 5-55 bars (50-bar trend scan)
Long: 28% (requires 64% directional consistency)
Short: -25% (requires 62% directional consistency)
Source: OHLC4 (reduces single-wick noise)
What Makes This Different
Unlike standard oscillators (RSI, MACD, Stochastic):
Not mean-reverting - designed to ride trends, not fade them
Context-aware - loop score measures sustained pressure, not just current momentum
Volatility-adaptive - ATR normalization works in both high and low vol regimes
State-based - holds positions through noise instead of flipping constantly
The for-loop mechanism is the key innovation: it requires a majority of recent history to show directional alignment before signaling, filtering out temporary spikes that destroy most momentum systems.
Core Concept
The GMI is a momentum oscillator that measures sustained directional pressure in price movements. It combines velocity analysis with a for-loop scanning system to identify medium-term trends while filtering out noise and false breakouts.
Architecture
1. Velocity Index Calculation
velocity_index = (price - EMA) / ATR
Components:
Price Source: OHLC4 (average of open, high, low, close)
Velocity Basis: 40-period EMA of price
Normalization: ATR(24) makes the indicator adaptive to volatility
Purpose: Measures how far price has deviated from its moving average, scaled by current market volatility. This creates a normalized momentum reading that works across different market conditions.
2. For-Loop Momentum Score
The core innovation. Scans 5-55 bars (50-bar window) and counts directional consistency:
For each bar from 5 to 55 bars ago:
- If velocity_index > velocity_index: +1 point
- If velocity_index < velocity_index: -1 point
Final Score = (net points / total bars) × 100
Output: A percentage score from -100% to +100%
+100% = every bar shows upward momentum
-100% = every bar shows downward momentum
0% = equal distribution
Why 5-55 bars?
Start at 5 to ignore immediate noise
End at 55 to capture medium-term trends
Creates a 50-bar scanning window
3. Drift Layer
A 34-period slower velocity calculation providing macro context. Plotted as a white line scaled ×20 to match the velocity display range. This shows the underlying trend while the velocity index shows short-term moves.
Signal Logic
Entry Conditions
LONG:
Loop score > 28% (meaning 64%+ of scanned bars are trending up)
Velocity index > 0 (confirming current upward momentum)
SHORT:
Loop score < -25% (meaning 62%+ of scanned bars are trending down)
Velocity index < 0 (confirming current downward momentum)
State Persistence
Uses a state machine (signal_state: -1, 0, 1) that:
Enters long when both conditions meet
Stays long until short conditions trigger
No exit on neutral - holds position through consolidation
This prevents excessive trading during sideways markets.
Visual Elements
Histogram (Primary Signal)
Shows loop score as columns
Color: Cyan above long threshold, navy below short threshold, gray in between
Direct visualization of trend strength
Velocity Line (Thick, 4px)
Scaled ×20 to overlay on histogram
Color matches signal state (cyan=long, navy=short, gray=neutral)
Shows immediate momentum
Drift Line (White, 2px)
Scaled ×20 for consistency
Provides slower context
Helps identify when velocity is aligned with macro trend
Background Fill
Subtle tint (94% transparency)
Cyan during long state
Navy during short state
Instantly shows current position
Threshold Lines
Long: 28 (cyan dashed)
Short: -25 (navy dashed)
Zero: 0 (gray solid)
Signal Markers
Triangle up (cyan) on new long
Triangle down (navy) on new short
Only appear on state changes, not every bar
Why It Works for Crypto
ATR Normalization: Adapts to Bitcoin/Ethereum's variable volatility
Medium-Term Focus: 50-bar scan catches trends lasting days/weeks
State Persistence: Doesn't exit on minor pullbacks
Asymmetric Thresholds: 28/-25 reflects crypto's tendency to trend up stronger than down
Velocity Confirmation: Prevents entries when loop score is positive but price is actually falling
Parameter Tuning Guide
Velocity Period (40):
Lower (20-30) = more sensitive, faster signals
Higher (50-60) = smoother, fewer signals
Loop Window (5-55):
Wider window = catches longer trends
Narrower window = responds faster to changes
Long Threshold (28):
Lower (20-25) = more entries, potentially more noise
Higher (35-40) = fewer, higher-conviction entries
Short Threshold (-25):
Higher (-20 to -15) = more short entries
Lower (-30 to -35) = more selective shorts
Current Optimized Settings (BTC/ETH 4H-1D)
Velocity: 40 periods (catches medium-term momentum shifts)
Loop: 5-55 bars (50-bar trend scan)
Long: 28% (requires 64% directional consistency)
Short: -25% (requires 62% directional consistency)
Source: OHLC4 (reduces single-wick noise)
What Makes This Different
Unlike standard oscillators (RSI, MACD, Stochastic):
Not mean-reverting - designed to ride trends, not fade them
Context-aware - loop score measures sustained pressure, not just current momentum
Volatility-adaptive - ATR normalization works in both high and low vol regimes
State-based - holds positions through noise instead of flipping constantly
The for-loop mechanism is the key innovation: it requires a majority of recent history to show directional alignment before signaling, filtering out temporary spikes that destroy most momentum systems.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.