OPEN-SOURCE SCRIPT

EGX Macro Relative Momentum

370
This is a macro momentum indicator that measures how the Egyptian stock market (EGX30) is performing relative to the USD/EGP exchange rate, essentially tracking whether local equities are outpacing currency devaluation or not.

Here's the breakdown by section:

Core Concept:
The indicator answers: "Is the stock market rising faster than the Egyptian Pound is falling against the Dollar?"

This matters because in country with currency volatility (like Egypt), nominal stock gains can be wiped out by currency devaluation.
This tool separates real market strength from currency-driven illusory gains.

Section-by-Section Explanation

Inputs:
EGX:EGX30 : The Egyptian stock market index
FX_IDC:USDEGP : USD to Egyptian Pound exchange rate
lookback : Rolling window for momentum accumulation (default: 20 bars) one month.

Calculations:
Rate of Change (ROC) Daily % change for both EGX30 and USD/EGP
Relative ROC: Subtracts currency movement from equity movement:
If EGX rises 2% and USD/EGP rises 1% → Relative ROC = +1% (market beating devaluation)
If EGX rises 2% and USD/EGP rises 3% → Relative ROC = -1% (market lagging devaluation)
Accumulation: Rolling sum of this relative momentum over your lookback period (smoothed via SMA × length)

Visualization:
Green histogram = Positive accumulated momentum (market strength exceeding currency pressure)
Red histogram = Negative accumulated momentum (market weakness or heavy devaluation pressure)
Background shading = Light green/red tint for quick visual context
Divergence Signals
Bullish divergence (▲): EGX rises while USD/EGP falls → Local market strength, currency recovery
Bearish divergence (▼): EGX falls while USD/EGP rises → Capital flight, devaluation stress

How to Read It:
Green bars rising: EGX is gaining real momentum beyond just currency effects, genuine bullish.
Red bars deepening: Market is selling off OR devaluation is outpacing any nominal gains, bearish.
Bullish divergence: Market rallying despite currency stability/strength, strong risk-on signal.
Bearish divergence: Market dropping while currency weakens, classic capital flight pattern.

Practical Use Cases:
Filtering trades: Only take long EGX positions when the indicator is green (positive relative momentum)
Macro regime detection: Sustained red bars suggest it's a "currency trade" not an "equity trade"
Your stock gains may not translate to real USD returns
Timing entries: Bullish divergences at support can signal capitulation; bearish divergences at resistance warn of exodus risk.

in options:
you can change EGX30 to EGX100: The indicator becomes more sensitive to the broad market health rather than just the banking/real state giants that dominate EGX30.
If you're trading smaller EGX names, EGX100 gives you better correlation to your actual universe.

Increasing Lookback from 20 → 60: Timeframe shift: On a daily chart, you're moving from ~1 month of accumulation to ~3 months.
Signal smoothing: The histogram becomes much slower and smoother, noisy daily wiggles get averaged out.
Lag increases: You'll detect macro trends later, but with higher conviction.

new update:
✅ Switching between stocks won't change the indicator values
✅ Values update once daily at market close (or on your chosen timeframe)
✅ You can manually change the timeframe in the indicator settings (gear icon) if you want weekly or hourly momentum
✅ Consistent readings across your entire EGX watchlist
To Change Timeframe Manually
Click the gear icon on the EGX Macro Relative Momentum indicator
Change Timeframe to "W" (weekly), "60" (hourly), etc.
All stocks will use the same timeframe setting

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.