OPEN-SOURCE SCRIPT
Mis à jour

SMA Indicator Signals [MK]

120
Overview
The SMA Indicator Signals [MK] indicator is designed to identify high-probability trend-following entries using a dual SMA system and RSI filtering. Unlike traditional crossover indicators that rely on ta.crossover (which often fails during volatile market gaps), this script uses state-based logic to capture signals even when the price "jumps" over the moving average.

The "Gap-Over" Problem Solved
In fast-moving markets or at market open, price often gaps significantly. If the price opens above the SMA 20 after being below it, a standard indicator usually misses the signal because no "physical" cross occurred on the chart.

This indicator compares the current state to the previous state. If the price is now above the SMA while previously being below, the signal triggers regardless of the gap.

Key Features
Persistent Signals: Unlike strategies that hide signals while a trade is active, this indicator plots an icon for every valid occurrence, allowing you to scale into positions or identify secondary entries.

Trend-Filtered: Long signals only appear when the 20 SMA is above the 50 SMA (and vice-versa for shorts).

RSI Guardrail: Built-in RSI logic prevents you from chasing "Longs" into overbought territory or "Shorts" into oversold conditions.

Universal Alerts: Includes pre-configured alertcondition calls for Longs, Shorts, or both.

How to Trade it
The Signal: Look for the Green (Long) or Red (Short) triangles.

User Discretion: Since this version removes automated ADX/Expansion filters, the trader should look at the "width" of the gap between the Blue (20) and Orange (50) SMAs. Wider gaps usually indicate stronger momentum.

Alerts: Create an alert and select "Any SSMA Signal" to be notified on your phone or desktop the moment a setup forms.

Settings
Fast SMA (20): Your primary trigger line.

Slow SMA (50): Your primary trend filter.

RSI Thresholds: Customize how "early" or "late" you want to be filtered out of a move based on momentum.
Notes de version
Change Log:
1. Strategy to Indicator Conversion

Converted the script from a strategy to an indicator.

Benefit: The script now displays every valid signal (Long/Short) on the chart. It no longer skips "in-between" signals that occur while a trade is technically active, allowing for better entry timing and scaling.

2. Gap-Resistant Entry Logic

Replaced the standard ta.crossover function with State-Based Detection.

Fix: The indicator now correctly triggers a signal even if the price gaps over the SMA 20 without physically touching it. If the current price is above the SMA and the previous price was below, a signal is generated immediately.

3. Real-Time Performance Dashboard (HUD)

Added a sleek, high-visibility table to the chart.

Displays live data for Trend Status (SMA 20/50 relationship), RSI value, and the SMA Gap (distance between the two moving averages).

Added a user setting to position the dashboard in any of the four corners of the chart.

4. Alert System Integration

Added alertcondition support.

Users can now set a single "Any SSMA Signal" alert to receive mobile or desktop notifications for every valid setup.

5. Pine Script v6 Optimization

Updated the code to the latest Pine Script v6 standards.

Improved table rendering stability and fixed color identifier errors (e.g., corrected color.lightblue to a custom RGB/Aqua for better visibility).
Notes de version
Overview
This indicator is designed for traders who follow the trend using Moving Average crossovers but require precise entry signals. It filters price action by identifying when the "Fast" SMA is in a favorable position relative to the "Slow" SMA and triggers a signal only when the price actively crosses the trigger line.

Core Logic
The script uses a three-tier confirmation system for signals:

Trend Filter: Signals are only generated when the SMA-20 is above the SMA-50 (for Longs) or below it (for Shorts).

Precise Trigger: Unlike indicators that signal whenever the price is "above" a line, this script requires a physical crossover (ta.crossover). This ensures you catch the momentum at the moment of the break.

Directional Selection: Users can toggle between "Long Only," "Short Only," or "Both" directly in the settings to align the indicator with their macro market bias.

Alerting Features (The Highlight)
This script is specifically optimized to avoid the common "Crossing Up/Down" manual setup in the TradingView Alert dialog.

Any alert() function call: By using this setting in the Alert menu, the indicator handles all math internally.

Directional Alerts: If you set the script to "Long Only," the alert will automatically ignore all short signals without you having to reconfigure the alert itself.

How to Use
Fast SMA (Default 20): Acts as your momentum and trigger line.

Slow SMA (Default 50): Acts as your trend baseline.

Signals: * Green Triangle: Long Signal (Price crossed above SMA-20 while SMA-20 > SMA-50).

Red Triangle: Short Signal (Price crossed below SMA-20 while SMA-20 < SMA-50).

Instructions for Setting Alerts
To get the most out of this indicator and avoid manual configuration:

Add the indicator to your chart and set your preferred Direction (Long/Short).

Open the Create Alert dialog.

Set Condition to Simple SMA Crossover Indicator.

Set the frequency to "Once Per Bar Close".

Select "Any alert() function call" as the trigger action.

Disclaimer
Financial Risk Warning: This indicator is for educational purposes only. Technical analysis indicators are based on historical data and do not guarantee future results. Trading involves significant risk of loss. Always use proper risk management and consult with a financial professional before making investment decisions.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.