OPEN-SOURCE SCRIPT
Diupdate Three EMA & RSI Strategy With Signals

3 EMA + RSI Strategy v3
User Documentation & Strategy Guide
TradingView Pine Script v5 Indicator
Version 3.0
Table of Contents
1. Strategy Overview
2. Installation & Setup
3. Input Parameters (GUI Settings)
4. Chart Visual Outputs
5. Information Table Reference
6. Alert Conditions
7. Strategy Logic (Detailed)
8. EMA Slope Line Colour Reference
9. Troubleshooting & Notes
1. Strategy Overview
The 3 EMA + RSI Strategy is a trend-following indicator built for TradingView. It combines four Exponential Moving Averages (EMAs) with a Relative Strength Index (RSI) filter and EMA slope analysis to identify high-probability long and short trade setups.
The strategy operates in two mutually exclusive regimes: Long Mode and Short Mode. At any given time, only one regime is active. Transitions between regimes are triggered by crossover events between the EMA Slow Medium and EMA Slow lines.
Core Components
• 4 EMAs: Fast, Medium, Slow Medium, and Slow. These define the trend structure and cloud.
• EMA Cloud: A shaded region between the Fast EMA and Slow EMA, coloured green (bullish) or red (bearish).
• EMA Slope Line: A continuous coloured line below the cloud showing the trend direction of the Slow Medium EMA. Green indicates upward slope, Red indicates downward slope, and Yellow indicates a flat/ranging market.
• RSI Filter: Multi-timeframe RSI used to confirm momentum before entry.
• Strong Candle Detection: Identifies candles with above-average body size relative to their total range, used to confirm entries and exits.
How It Works (Summary)
1. An EMA crossover (Slow Medium crossing Slow) activates a regime and fires a Yellow Star signal.
2. Within the active regime, a Strong Candle closing in the correct position relative to the Medium and Slow Medium EMAs triggers an entry (Green or Red triangle).
3. A Strong Candle closing against the position relative to the Medium EMA triggers an exit (Violet triangle).
4. The EMA Slope Line and RSI circles provide additional confluence confirmation throughout.
2. Installation & Setup
• Open TradingView and navigate to the Pine Editor (bottom panel).
• Click 'Open' or create a new script, then paste the entire Pine Script code.
• Click 'Add to Chart'. The indicator will appear on your active chart.
• Access settings via the gear icon on the indicator title bar to configure inputs.
• Set up alerts via the TradingView Alerts dialog, selecting the indicator's alert conditions.
3. Input Parameters (GUI Settings)
All inputs are accessible through the indicator's Settings panel on TradingView. They are organised into the following groups.
3.1 EMA Settings
Parameter Default Description
EMA Fast Length 9 Period for the Fast EMA. Shortest and most responsive. Forms the upper/lower boundary of the cloud.
EMA Medium Length 21 Period for the Medium EMA. Used as a threshold for strong candle entry and exit confirmations.
EMA Slow Medium Length 50 Period for the Slow Medium EMA. The primary signal line. Its crossover with the Slow EMA triggers regime changes. Its slope is measured for trend strength.
EMA Slow Length 200 Period for the Slow EMA. The anchor line. Forms the other boundary of the cloud. Regime direction is determined by the Slow Medium EMA crossing above or below this line.
3.2 RSI Settings
Parameter Default Description
RSI Resolution From Chart Timeframe for RSI calculation. Options: From Chart, 5 Min, 10 Min, 15 Min. This also governs the update frequency of RSI circles and slope labels.
RSI Average Period 14 RSI lookback period. Also used as a multiplier: RSI Resolution x this value is displayed in HH:MM:SS format in the table.
RSI Threshold Long 55.0 RSI must be greater than or equal to this value for a green (bullish) RSI circle in Long Mode.
RSI Threshold Short 45.0 RSI must be less than or equal to this value for a green (bearish confirmation) RSI circle in Short Mode.
3.3 EMA Slope Settings
Parameter Default Description
Slope Lookback Periods 3 Number of RSI-resolution bars to look back. Slope = (current EMA Slow Medium - value N bars ago) / value N bars ago x 100. Higher values smooth the slope reading.
EMA Long Slope Threshold 0.05 Minimum slope percentage for a 'strong uptrend' confirmation in Long Mode. Used in table display.
EMA Short Slope Threshold -0.05 Maximum slope percentage (negative) for a 'strong downtrend' confirmation in Short Mode. Used in table display.
EMA Flat Threshold 0.02 When the absolute slope value is below this threshold, the slope reading is considered flat. Contributes to ranging detection.
Flat Confirmation 3 Number of consecutive HTF bars where slope remains flat before the market is declared 'RANGING'. This prevents false flat signals from a single bar.
3.4 Strong Candle Settings
Parameter Default Description
Body > Avg Body x This 1.5 The candle body must be this multiplier times larger than the average body over the lookback period.
Average Lookback Bars 20 Number of bars used to calculate the average body size. Larger values create a more stable baseline.
Min Body % of Range 50% Minimum ratio of candle body to total high-low range. Filters out dojis and spinning tops that have large wicks but small bodies.
4. Chart Visual Outputs
The indicator renders the following visual elements directly on the price chart. Each element has a specific meaning and purpose.
4.1 EMA Lines
EMA Colour Purpose
Fast Yellow Fastest-reacting EMA. Forms one edge of the cloud.
Medium Orange Entry/exit threshold. Strong candles must close above (long) or below (short) this line.
Slow Medium Blue Primary signal EMA. Its crossover with the Slow EMA triggers regime changes. Slope is measured.
Slow White Anchor EMA. Forms the other edge of the cloud.
4.2 EMA Cloud
The shaded region between the Fast EMA and the Slow EMA provides an at-a-glance view of the trend regime.
• Green Cloud: Active after the Slow Medium EMA crosses above the Slow EMA (bullish regime).
• Red Cloud: Active after the Slow Medium EMA crosses below the Slow EMA (bearish regime).
• Grey Cloud: Initial state before any crossover has occurred.
4.3 Chart Markers (Shapes)
Signal Shape Colour Meaning
EMA Cross Long Diamond (★) Yellow Slow Medium EMA crossed above Slow EMA. Long Mode activated. This is the initial setup signal for a potential long trade.
EMA Cross Short Diamond (★) Yellow Slow Medium EMA crossed below Slow EMA. Short Mode activated. This is the initial setup signal for a potential short trade.
Long Entry Triangle Up Green A strong bullish candle closed above both the Medium EMA and Slow Medium EMA while in Long Mode. Entry confirmation.
Short Entry Triangle Down Red A strong bearish candle closed below both the Medium EMA and Slow Medium EMA while in Short Mode. Entry confirmation.
Long Exit Triangle Down Violet A strong bearish candle closed below the Medium EMA while a Long Entry was active. Position should be closed.
Short Exit Triangle Up Violet A strong bullish candle closed above the Medium EMA while a Short Entry was active. Position should be closed.
4.4 RSI Circles
Coloured circles appear above the candle wick in Long Mode or below the candle wick in Short Mode. They are updated once per RSI Resolution bar.
• Green Circle (●): RSI condition is met. In Long Mode, RSI >= Long Threshold. In Short Mode, RSI <= Short Threshold.
• Red Circle (●): RSI condition is not met.
Click on any circle to view a tooltip showing the exact RSI value and threshold.
4.5 EMA Slope Line Colour Reference
The EMA Slope Line is a continuous coloured line drawn below the EMA Cloud. It represents the rate of change (slope) of the Slow Medium EMA over the configured lookback period. The line is labelled on the chart at the rightmost bar for easy identification.
The line uses a three-colour system that applies identically in both Long and Short modes:
Colour Condition Interpretation
GREEN Slope >= 0 The Slow Medium EMA is trending upward. The EMA value is higher now than it was N lookback periods ago. This indicates bullish momentum in the underlying trend.
RED Slope < 0 The Slow Medium EMA is trending downward. The EMA value is lower now than it was N lookback periods ago. This indicates bearish momentum in the underlying trend.
YELLOW |Slope| < Flat Threshold for N consecutive bars The Slow Medium EMA is essentially flat. The market is in a ranging/consolidation phase. Trade signals during this period should be treated with extra caution as EMA crossovers in ranges tend to produce false signals.
The slope line does not render on bars where insufficient data is available (i.e., before the lookback buffer is filled). This prevents misleading readings on early chart history.
Click anywhere on the slope line to view a tooltip displaying the precise slope percentage, flat counter progress, and all configured thresholds.
5. Information Table Reference
A real-time information table is displayed in the top-right corner of the chart. It provides an at-a-glance summary of all internal states.
Row Description
RSI Resolution The currently selected RSI timeframe (e.g., From Chart, 5 Min).
RSI Res x Avg The effective RSI analysis window in HH:MM:SS format. Calculated as RSI Resolution (in minutes) multiplied by the RSI Average Period.
Active Mode Current regime: LONG (green), SHORT (red), or NONE (grey). Only one mode is active at a time.
Market Condition TRENDING UP (green), TRENDING DOWN (red), or RANGING (yellow). Based on slope direction and flat detection.
Flat Count Progress towards ranging detection, shown as current/required (e.g., 2/3). Turns yellow when ranging is confirmed.
EMA Cross Long/Short Whether the initial crossover condition is active. TRUE (green) or FALSE (red). Shows N/A when the opposite mode is active.
Long/Short Strong Entry Whether an entry has been confirmed by a strong candle. TRUE (green) means a position is open. FALSE (red) means no entry yet or position was exited.
EMA Slope Current slope value as a percentage. Coloured green (up), red (down), or yellow (ranging). Shows N/A when the opposite mode is active.
RSI Avg Current RSI value. Green if the threshold condition is met, red otherwise. Shows N/A when the opposite mode is active.
Slope Lookback Configured number of HTF bars used for slope calculation.
Strong Candle? Whether the current (last) bar qualifies as a strong candle. Displays BULL, BEAR, or No.
6. Alert Conditions
The indicator provides seven configurable alert conditions. To enable alerts, right-click the indicator on the chart and select 'Add Alert', then choose the desired condition.
Alert Name Trigger Condition
EMA Cross Long Slow Medium EMA crosses above Slow EMA. Long Mode begins.
EMA Cross Short Slow Medium EMA crosses below Slow EMA. Short Mode begins.
Long Strong Entry A strong bullish candle closes above both Medium and Slow Medium EMAs while in Long Mode.
Short Strong Entry A strong bearish candle closes below both Medium and Slow Medium EMAs while in Short Mode.
Long Exit Signal A strong bearish candle closes below the Medium EMA while a long entry is active.
Short Exit Signal A strong bullish candle closes above the Medium EMA while a short entry is active.
Ranging Detected The EMA slope has remained flat (below the flat threshold) for the configured number of consecutive HTF bars.
7. Strategy Logic (Detailed)
7.1 Regime Determination
The strategy uses a state machine with two mutually exclusive modes. When one mode activates, the opposite mode's state variables are invalidated and reset.
• Long Mode Activation: Triggered when the EMA Slow Medium crosses above the EMA Slow (bullish crossover). The Short Mode states are immediately reset.
• Short Mode Activation: Triggered when the EMA Slow Medium crosses below the EMA Slow (bearish crossover). The Long Mode states are immediately reset.
7.2 Long Trade Lifecycle
Step 1 - Setup (Yellow Star): The Slow Medium EMA crosses above the Slow EMA. A yellow diamond marker appears above the bar. The internal state 'EMA Cross Long' is set to TRUE. An alert fires.
Step 2 - Entry (Green Triangle): While EMA Cross Long is TRUE, a strong bullish candle closes above both the Medium EMA and the Slow Medium EMA. A green upward triangle appears below the bar. The internal state 'Long Strong Entry' is set to TRUE. An alert fires. This represents the long entry confirmation.
Step 3 - Exit (Violet Triangle): While Long Strong Entry is TRUE, a strong bearish candle closes below the Medium EMA. A violet downward triangle appears above the bar. The internal state 'Long Strong Entry' is reset to FALSE. An alert fires. This represents the signal to close the long position.
7.3 Short Trade Lifecycle
Step 1 - Setup (Yellow Star): The Slow Medium EMA crosses below the Slow EMA. A yellow diamond marker appears below the bar. The internal state 'EMA Cross Short' is set to TRUE. An alert fires.
Step 2 - Entry (Red Triangle): While EMA Cross Short is TRUE, a strong bearish candle closes below both the Medium EMA and the Slow Medium EMA. A red downward triangle appears above the bar. The internal state 'Short Strong Entry' is set to TRUE. An alert fires. This represents the short entry confirmation.
Step 3 - Exit (Violet Triangle): While Short Strong Entry is TRUE, a strong bullish candle closes above the Medium EMA. A violet upward triangle appears below the bar. The internal state 'Short Strong Entry' is reset to FALSE. An alert fires. This represents the signal to close the short position.
7.4 EMA Slope Calculation
The EMA slope measures the rate of change of the Slow Medium EMA over the configured lookback period. It is recalculated once per RSI Resolution bar (Higher Timeframe bar).
Formula: Slope = (Current EMA Slow Medium - EMA Slow Medium N bars ago) / EMA Slow Medium N bars ago x 100
Where N is the Slope Lookback Periods setting. The result is expressed as a percentage.
7.5 Ranging Detection
When the absolute value of the slope remains below the Flat Threshold for the configured number of consecutive HTF bars (Flat Confirmation), the market is declared as RANGING. During ranging conditions, the slope line turns yellow and the table displays 'RANGING' as the market condition. Traders should exercise additional caution during ranging periods as EMA-based signals are prone to whipsaws.
7.6 Strong Candle Criteria
A candle is classified as 'strong' when all three of the following conditions are satisfied simultaneously:
• Body Size: The absolute difference between open and close must exceed the simple moving average of body sizes over the lookback period, multiplied by the configured body multiplier.
• Body Percentage: The ratio of body size to the total high-low range must meet or exceed the minimum body percentage threshold.
• Non-Zero Range: The high-low range must be greater than zero (eliminates flat/no-trade bars).
A strong candle is further classified as bullish (close > open) or bearish (close < open) to determine its role in entry and exit logic.
8. EMA Slope Line Colour Summary
For quick reference, the slope line on the chart uses the following colour encoding. This applies uniformly regardless of whether the strategy is in Long Mode or Short Mode.
Colour Slope Value Market State Recommendation
GREEN Slope >= 0 Uptrend Favourable for long entries when supported by other signals.
RED Slope < 0 Downtrend Favourable for short entries when supported by other signals.
YELLOW |Slope| < Flat Threshold (N consecutive bars) Ranging / Flat Exercise caution. EMA crossover signals in ranging markets are prone to false triggers.
9. Troubleshooting & Notes
Common Issues
• Slope line not visible on older bars: This is by design. The slope line requires the lookback buffer to be filled before rendering. Increase the chart history or reduce the lookback period.
• No signals appearing: Verify that the EMA lengths are appropriate for your timeframe. On very short timeframes, a 200-period Slow EMA may require substantial history.
• Strong candles not detected: Try reducing the Body Multiplier (e.g., from 1.5 to 1.2) or the Min Body Percentage (e.g., from 50% to 40%).
• RSI circles not updating frequently enough: RSI circles update once per RSI Resolution bar. If your chart timeframe is smaller than the RSI Resolution, updates will appear less frequently.
Important Notes
• This indicator is a technical analysis tool, not a trading system with automated order execution. All signals should be used as part of a comprehensive trading plan.
• Long and Short modes are mutually exclusive. When one mode activates, the other mode's state variables are displayed as 'N/A' in the table.
• The EMA Slope Line colour is unified across both regimes: green always means the EMA is rising, red always means it is falling, and yellow always means it is flat.
• Tooltip information is available by hovering over or clicking on RSI circles and the slope line.
• Always validate indicator signals with your own analysis and risk management framework.
End of Documentation
Catatan Rilis
Warning SystemThe information table includes a dedicated Warning row that provides real-time risk alerts. The warning system detects three conditions where the current market state conflicts with the active regime or blocks entries entirely.
Warning Message Colour Meaning & Recommended Action
⚠ RANGING — Entries Blocked Yellow The market is in a confirmed ranging state. Entry signals are blocked. Do not attempt manual entries. Wait for the slope to exit the flat zone and the warning to clear.
⚠ Slope DOWN vs LONG Regime Orange Long Mode is active but the EMA Slow Medium slope is negative (trending downward). The underlying trend momentum is working against the long bias. Exercise heightened caution with any open or pending long positions.
⚠ Slope UP vs SHORT Regime Orange Short Mode is active but the EMA Slow Medium slope is positive (trending upward). The underlying trend momentum is working against the short bias. Exercise heightened caution with any open or pending short positions.
None Green No conflict detected. The slope direction is aligned with the active regime and the market is not ranging. Conditions are favourable for the active strategy.
The warning row has an amber/dark background when active, making it visually prominent. The ranging warning takes priority over slope-conflict warnings since it directly blocks entries. Only one warning is displayed at a time, prioritised as: Ranging > Slope Conflict.
Catatan Rilis
v3.4 Release NotesNew Features:
Entry Logic Mode — GUI dropdown with two options: Strong Candle (original price-action based) and EMA Alignment (Fast EMA position relative to Medium & Slow Medium). Applies to both entry AND exit logic.
RSI-Based Entry Block — Entries are only permitted when RSI meets the mode threshold on BOTH the current bar AND the average over the last N HTF bars. If either condition fails, entry is blocked regardless of all other signals. This ensures sustained RSI momentum before any trade is taken.
Collapsible Table Sections — Long, Short, and Config sections toggle via checkboxes in Table Display settings. ▼ = expanded, ▶ = collapsed. Table dynamically resizes with indented detail rows.
Adjustable Font Size — Tiny / Small / Normal / Large dropdown. Header row always one step larger than detail rows.
Entry Cond / Exit Cond Rows — Live TRUE/FALSE indicators in both Long and Short sections. Entry Cond checks all entry conditions in real time. Exit Cond uses violet when TRUE.
RSSI
Bug Fixes:
Cloud colour now correctly follows the selected EMA Cross Mode (was hardcoded to Slow Medium × Slow).
Catatan Rilis
Latest document here:filebin.net/u3gw63ycqbantoaz
Could not modify the tradingview page. Please download here.
Catatan Rilis
Done. New Signal Timing toggle added under EMA Settings:SettingBehaviorBar Close (default)All signals (cross, entry, exit) wait for the candle to close via barstate.isconfirmed. Avoids fakeouts from mid-bar wicks.
Live TickSignals fire immediately as conditions are met on live price
Catatan Rilis
Latest doc word document here:filebin.net/wwz0dpxisezity1t
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.