OPEN-SOURCE SCRIPT
Güncellendi

EMA Slope - RSI Oscillator Strategy

10 079
**EMA Slope Strategy** combines normalized EMA slope momentum with centered RSI to build a multi-entry system for both continuation and reversal setups. It uses a global No Trade Zone (NTZ) to block weak signals, optional divergence modules, RSI-Slope oscillator entries, and entry-type-specific trailing management.

**Core Concept - Arctan Slope Normalization:** The strategy measures the change in a long moving average and normalizes it with an arctan model to a centered range that asymptotically approaches +/-50. This keeps slope and centered RSI on comparable scales without hard clipping, making momentum relationships more realistic across different volatility regimes.

**Global NTZ Filter:** The NTZ acts as a full entry blocker when enabled. No new entries are allowed while normalized slope is inside the zone, including reversals. This keeps the strategy focused on stronger momentum conditions while still allowing exits inside the NTZ.

**Entry Engine:** The script supports NTZ Cross, Acceleration, RSI Divergence, Slope-RSI Divergence, and RSI-Slope Oscillator entries. The oscillator now checks NTZ only on the initial cross, then waits for RSI and slope to keep moving in the same direction within a timeout window.

**Trade Management Enhancements:** Same-direction stacking is blocked, but opposite-direction entries can still reverse positions cleanly. Old trailing-stop state is cleared on reversal so only the new side remains active. Standard entries can optionally exit on NTZ re-entry, while divergence and oscillator entries use their own ATR-based trailing logic and grace periods.

Default values were tested in BTCUSDT 15min market.

### 🎯 Key Features

✅ **Global No Trade Zone (NTZ)** - Blocks all new entries while slope is inside the neutral zone
✅ **Momentum-Based Entries** - Requires minimum delta to filter weak signals
✅ **Stretch Filter** - Prevents entries when MAs are overextended
✅ **Trend Confirmation** - Optional filter ensures trades align with trend
✅ **Acceleration Entry** - Alternative entry on sudden slope acceleration
✅ **RSI Divergence Entries** - Detect reversals with multi-peak divergence analysis
✅ **Slope-RSI Exhaustion** - Visual warnings and optional filter using normalized momentum comparison
✅ **RSI-Slope Oscillator Entries** - Arms on a valid cross outside NTZ, then confirms with same-direction RSI and slope movement
✅ **Side-Aware Reversals** - Blocks same-direction add-ons while still allowing opposite-side reversals
✅ **RSI-Slope Cross Exit** - Optional close/reverse for any position when RSI and slope cross with same-direction momentum
✅ **Exit Confirmation** - Requires consecutive bars to filter false exit signals
✅ **Entry-Type Trailing Stops** - Separate ATR trails and grace periods for standard, divergence, and oscillator trades
✅ **Immediate Trail Reset On Flip** - Disables the old side's stop state as soon as a reversal is triggered
✅ **Individual Entry Type Controls** - Enable/disable each entry method independently
✅ **Dynamic RSI Coloring** - Visual RSI coloring based on overbought/oversold levels
✅ **Flexible Position Sizing** - Percent of Equity, Fixed Quantity, or Percent of Cash
✅ **Built-in Alerts** - Entry/exit alerts with trade details

### 📊 Technical Calculations

**Slope Normalization Formula:** `maDF = longMA - longMA[smoothBars]`, then `normalizedSlope = (100 / pi) * atan(maDF / stdev(maDF, lookback))`. This produces a centered oscillator that asymptotically approaches +/-50 and stays comparable with centered RSI.

**Acceleration Detection:** Calculates the absolute change in slope between bars, multiplied by smoothing factor and scaled to 0-50 range. Values above threshold (default 38) indicate sudden momentum shifts, visualized as colored dots.

**RSI Divergence:** Uses pivot high/low detection on smoothed RSI with configurable sensitivity (lookback = 16 - sensitivity). Compares price pivots against RSI pivots to identify divergences: bullish when price makes lower lows while RSI makes higher lows, bearish when price makes higher highs while RSI makes lower highs.

**Slope-RSI Exhaustion:** Compares normalized EMA slope momentum against centered RSI (RSI - 50) on the same scale. When slope is accelerating in one direction but RSI is moving opposite over multiple lookback periods, it indicates trend exhaustion. The gap between slope and RSI must exceed threshold (default 10.0 points) to filter noise.

**RSI-Slope Oscillator:** Detects when centered RSI crosses normalized slope outside the NTZ, then waits for both RSI and slope to continue moving in the same direction within a timeout window. This allows reversal-style entries without requiring the slope to stay outside the NTZ after the cross.

**Trailing Stop (Blackflag FTS Swingarm):** Uses Wilder's moving average of true range (modified or standard) multiplied by ATR factor. Separate trailing stops for different entry types: Standard entries (NTZ Cross, Acceleration) use standard ATR factor with grace period (default 3 bars). Divergence entries use wider ATR factor (default 6.0) with grace period (default 5 bars). RSI-Slope Oscillator entries use wider ATR factor (default 6.0) with grace period (default 3 bars). Grace periods prevent immediate exits after entry.

**Visual Indicators:** Green/Red = trend direction, Gray = NTZ zone, Colored dots = acceleration, Centered RSI line (RSI-50) with dynamic coloring (Red when overbought >20, Green when oversold <-20, Neutral when between -20 and 20), Purple/Lime diamonds = price-RSI divergence, Orange/Yellow triangles = slope-RSI exhaustion warnings, Information table showing Slope, cRSI, Gap, and P/L%

### ⚙️ Quick Setup

**Defaults:** MA: 40/160 EMA, NTZ: 8, Delta: 3.2, Stretch: 0.38%, Position: 90% Equity, Exit Confirm: 1 bar, Trail Stop: ATR 15/Factor 5.1, Entry ATR: Period 10/Factor 4.4, RSI: Length 12/Smooth 3/Sensitivity 6, Div ATR: 6.0/Grace 5, Slope-RSI: Lookback 4/Gap 10.0 pts, Osc ATR: 6.0/Grace 3, Standard Grace: 3 bars, Max Crossing Back Period: 5 bars

### 🚀 Entry Methods and Logic

**Long Entry Conditions (5 Methods):**

1. **NTZ Cross Entry:** Triggers when normalized slope crosses above +8 threshold. Requires positive delta ≥ minimum threshold (default 3.2), stretch filter allows entry (MAs not overextended), and optional trend confirmation (short MA > long MA) if enabled. This is the primary trend-following method.

2. **Acceleration Entry:** Triggers when acceleration value ≥ threshold (default 34) AND slope is already above NTZ AND delta is sufficient. This captures sudden momentum bursts during strong trends, visualized as colored dots on the indicator.

3. **RSI Divergence Entry:** Triggers when bullish divergence detected - price makes a lower low while RSI makes a higher low over the sensitivity lookback period. Optional Slope-RSI confirmation can be required. This targets reversal opportunities at potential bottoms.

4. **Slope-RSI Divergence Entry:** Triggers when slope is accelerating downward (negative delta, slope below -8) but RSI is rising over lookback periods, with gap between slope and RSI exceeding threshold. This detects bullish exhaustion reversals during downtrends.

5. **RSI-Slope Oscillator Entry:** Triggers when centered RSI crosses normalized slope outside the NTZ, then confirms when both RSI and slope keep moving in the same direction within the allowed timeout window. This targets reversal-style entries while the global NTZ filter still blocks final entries inside the zone.

**Short Entry Conditions:** Mirror of long conditions with opposite directional requirements.

**Exit Logic by Entry Type:**

- **NTZ/Acceleration Entries:** Exit when slope re-enters NTZ, if that option is enabled, or when the standard trailing stop triggers after its grace period.

- **Divergence Entries (RSI or Slope-RSI):** Exit only via divergence-specific trailing stop which uses wider ATR factor (default 6.0, adjustable 4-8) and grace period (default 5 bars) before activation. This allows reversal trades time to develop without premature exits.

- **RSI-Slope Oscillator Entries:** Exit when the opposite oscillator condition triggers or when the oscillator-specific trailing stop is hit after its grace period.

- **RSI-Slope Cross Exit (All Entry Types):** Optional exit/reverse condition that applies to ALL positions. When enabled, exits or reverses position when RSI crosses Slope with both indicators moving in the same direction. Bearish: RSI crosses below Slope AND both heading DOWN (exits/reverses longs). Bullish: RSI crosses above Slope AND both heading UP (exits/reverses shorts). Can be set to reverse position or close only.

### 📖 How-To Guide

**Add to Chart:** Indicators → Search "EMA Slope Strategy" → Select

**Parameter Configuration Guide:**

- **MA Settings**: Two moving averages required. Short MA (default 40) used for stretch filter calculation. Long MA (default 160) used for slope calculation. Ratios: 20/80 (fast, more signals), 40/160 (standard, balanced), 50/200 (slow, fewer but stronger signals). EMA recommended for responsiveness.

- **NTZ Threshold**: Controls minimum momentum required for entries. Lower values (5-6) generate more trades but may include weaker signals. Higher values (10-12) generate fewer but stronger momentum signals. Default 8 balances frequency with quality.

- **Stretch Filter**: Percentage difference threshold between MAs (default 0.38%). For longs: blocks when long MA > short MA by threshold amount. For shorts: blocks when long MA < short MA by threshold amount. Lower (0.2-0.3%) = more conservative, higher (0.5-1.0%) = more permissive. Set to 0 to disable.

- **Delta Threshold**: Minimum change in normalized slope between bars required for entry (default 3.2). Higher values (5-10) require stronger momentum, lower (1-3) are more sensitive. This filters out minor slope fluctuations.

- **Exit Confirmation Bars**: Number of consecutive bars exit conditions must persist before closing (default 1). 0 = immediate exit, 1-3 = filters false exit signals during temporary pullbacks, higher = more tolerant. Only applies to NTZ re-entry exits, not trailing stops or RSI-Slope cross exits.

- **Trailing Stop**: Blackflag FTS Swingarm method using ATR-based calculation. Trailing Stop ATR Period (default 15) and Factor (default 5.1) control stop distance. Entry ATR Period (default 10) and Factor (default 4.4) control initial stop loss. Separate ATR factors and grace periods for standard entries (default grace 3 bars), divergence entries (default ATR factor 6.0, grace 5 bars), and oscillator entries (default ATR factor 6.0, grace 3 bars). Grace periods prevent immediate exits after entry.

- **RSI Divergence Settings**: Sensitivity (6-10, default 6) controls pivot lookback (inverse relationship - higher = more sensitive). Max Peaks to Compare (2-15, default 8) controls how many previous peaks to check. Grace bars (2-5, default 5) delay trailing stop activation. Divergence ATR Factor (4-8, default 6.0) sets stop width for reversal trades. Optional Slope-RSI confirmation can be required for higher quality signals.

- **Slope-RSI Settings**: Lookback bars (2-10, default 4) determines how many periods to compare RSI direction against slope. Gap threshold (10.0 pts default) filters weak divergences - minimum distance between EMA Slope and Centered RSI. Set gap to 0 to disable threshold. Can be used as entry method (counter-trend reversals) or as confirmation filter for RSI divergence entries.

- **RSI-Slope Oscillator Settings**: ATR Factor (4-8, default 6.0) for trailing stop width. Grace bars (2-5, default 3) before stop activates. Max Crossing Back Period (1-50, default 5) controls timeout window for entry after cross. Allows position reversal when opposite signal triggers.

- **RSI-Slope Cross Exit**: Optional exit/reverse condition. When enabled, exits or reverses position when RSI crosses Slope with both moving in same direction. Can be set to reverse position or close only. Applies to all entry types.

- **Entry Type Controls**: Individual checkboxes to enable/disable each entry method: NTZ Cross Entries, Acceleration Entry, RSI Divergence Entries, Slope-RSI Divergence Entries, RSI-Slope Oscillator Entries. Allows fine-tuning which entry methods are active.

- **RSI Display**: Dynamic RSI coloring option (enabled by default). RSI line changes color based on overbought/oversold levels: Red when cRSI > 20, Green when cRSI < -20, Neutral when between -20 and 20. Customizable colors and line width.

**Alerts:** Right-click chart → Add Alert → Select "EMA Slope Strategy" → Choose condition → Configure notifications
**Backtest:** Strategy Tester tab → Select strategy → Set date range & capital → Review results
**Panel Interpretation:** Green/Red = trend, Gray = NTZ, Dots = acceleration, Blue = Centered RSI, Purple/Lime = price-RSI divergence, Orange/Yellow = slope-RSI exhaustion
**Multi-Timeframe:** Higher timeframe for trend, lower for entries. **Market Adjustments:** Crypto: 20/80 MA, NTZ 6-7 | Forex: 40/160, NTZ 8 | Stocks: 50/200, NTZ 10-12

### 💡 Usage Guidelines

**Timeframe Recommendations:** Day Trading: 5m-15m charts work well with faster MA settings (20/80). Swing Trading: 1h-4h charts with standard settings (40/160). Position Trading: 4h-Daily charts with slower settings (50/200).

**Entry Method Selection:** Use individual entry type controls to enable/disable methods based on market conditions. NTZ Cross and Acceleration work best in trending markets. RSI Divergence and Slope-RSI Divergence work best at potential reversal points. RSI-Slope Oscillator works best for trend reversals when momentum indicators align. You can enable multiple methods simultaneously or use them individually.

**Risk Management:** Always validate signals with price action and support/resistance levels. Use position sizing to limit risk to 1-2% of capital per trade. Exit Confirmation bars (default 6) help filter false exits during normal market volatility. Divergence and oscillator entries use wider stops (ATR factor 6.0) with grace periods (3 bars) because reversals need room to develop. Standard entries use tighter stops (ATR factor 4.7) with shorter grace period (2 bars). RSI-Slope Cross Exit provides additional exit mechanism that can reverse positions when momentum shifts.

**Market-Specific Adjustments:** Crypto markets: Use faster MAs (20/80), lower NTZ (6-7), higher delta (4-5). Forex: Standard settings (40/160 MA, NTZ 8, Delta 3.2). Stocks: Slower MAs (50/200), higher NTZ (10-12), lower delta (2-3). Always backtest parameter combinations for your specific market and timeframe before live trading.

### 🔔 Alert System

The strategy includes built-in alert conditions for all entry and exit events. Entry alerts include: entry method type (NTZ Cross, Acceleration, RSI Divergence, Slope-RSI Divergence, or RSI-Slope Oscillator), entry price, calculated position size, current normalized slope value, delta value, acceleration value, RSI value, trend confirmation status, Slope-RSI confirmation status (if enabled), and timestamp. Exit alerts include: exit price, original entry price, position size, profit/loss amount and percentage, exit reason (trailing stop, NTZ re-entry, RSI-Slope Cross, or position reverse), current slope and RSI values, confirmation bars count (for NTZ exits), and timestamp. Set up alerts by right-clicking the chart, selecting "Add Alert", choosing the strategy, and selecting which conditions to monitor.

### 📈 Use Cases

Day Trading (5m-15m), Swing Trading (1h-4h), Position Trading (4h-Daily), Trend Following, Momentum Trading, Reversal Trading, Range Trading

### ⚠️ Important Disclaimer

**THIS IS NOT FINANCIAL ADVICE**

This strategy is for educational purposes only. Trading involves substantial risk of loss and is not suitable for all investors. Past performance does not guarantee future results.

**Key Points:** No guarantee of profits - you may lose capital. Not professional financial advice - consult a qualified advisor. Trade only with capital you can afford to lose. Backtest results don't guarantee future performance. You are solely responsible for trading decisions and risk management.

**By using this strategy, you acknowledge understanding the risks and that you use it at your own risk. Never invest more than you can afford to lose.**

**Works on all markets**: Crypto, Forex, Stocks, Commodities, Futures


## Short Description (for Script Header - 200-300 chars)

Multi-entry strategy combining arctan-normalized EMA slope with centered RSI. Includes a global NTZ entry filter, NTZ/acceleration/divergence/oscillator signals, side-aware reversals, optional NTZ re-entry exits, and separate trailing stops with grace periods for each entry type.

## Tags (for Publishing)

EMA, Moving Average, Slope, Trend Following, Momentum, No Trade Zone, NTZ, Strategy, Trading Strategy, Technical Analysis, Trailing Stop, Position Sizing, Acceleration, Delta, Stretch Filter, Trend Confirmation, RSI, Divergence, Slope-RSI, Exhaustion, RSI-Slope Oscillator, Normalized Comparison, Exit Confirmation, Alerts, Backtesting, Crypto, Forex, Stocks, Futures, Swing Trading, Day Trading, Reversal Trading, Range Trading

## Category

**Strategies** → **Trend Following**
Sürüm Notları
2026 April

Added last bar confirmation filter to avoid entries when last bar goes wrong direction.
Sürüm Notları
Change log 2026-04-05

// RSI-Slope Oscillator: blocked RSI–slope cross now clears pending oscillator wait (fixes stale arm completing after a later exhaustion cross).
// Version 1.3.10
// RSI-Slope Oscillator: optional filter blocks arming when cross happens with both RSI and slope already past NTZ (exhaustion-style chase).
Sürüm Notları
Minor changes in settings and table display problems. Work well with BTC/USDT 15 min
Sürüm Notları
// Version 1.3.8
// Table: reduce left spacer and make spacer column transparent.
// Table: left spacer column (% width) to clear TradingView pane logo over bottom-left anchor.
// Table: populate on islast OR islastconfirmedhistory (TV tables doc — strategies + calc_on_every_tick=false).
// Slope-RSI metrics table: bottom-left, no overlay (indicator pane only).
// line.new: use xloc.bar_time for Slope-RSI and RSI divergence connectors (fixes TV limit on bar_index span).

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.