OPEN-SOURCE SCRIPT
EMA 5/30 Alert Strategy Custom SL/TP

The trading style and process you’re using is best described as a **systematic, algorithmic momentum strategy** that centers around moving average crossovers with custom stoploss logic and clear alert-based execution.
***
### Trading Style
- **Strategy Base:** Uses exponential moving averages (EMA) as the core technical indicator, specifically a 5-period and a 30-period EMA for primary market structure and trend detection.
- **Trade Signals:** Buy signals are generated when the short EMA (5) crosses above the long EMA (30), and sell signals occur when the short EMA crosses below the long EMA.
- **Automation & Alerts:** The process is made actionable via `alertcondition()` in Pine Script, allowing the use of TradingView automation or webhook connections, enabling both notifications and the potential for algo/bot execution of trades.
- **Visual Feedback:** Signal points are highlighted on the chart with shapes/labels, ensuring that each entry and exit is immediately visible and easy to verify visually.
- **Risk & Stop Filtering:** Instead of a fixed-point or percent stoploss, your scripts use a volatility-adaptive stoploss based on the Average True Range (ATR), which is multiplied by a user-defined factor (for example, 2x ATR below/above entry) to create a dynamic, context-aware stop filter.
- **Customizability:** The length of EMAs and ATR period, as well as stoploss multipliers, are adjustable, making the system flexible for tuning to different markets and timeframes.
***
### Trading Process
- At every new bar, calculate the 5-EMA, 30-EMA, and ATR.
- If a crossover event occurs:
- **Buy Entry:** 5-EMA crosses above 30-EMA; script enters long and places a stoploss at (entry − n × ATR).
- **Sell Entry:** 5-EMA crosses below 30-EMA; script enters short and places a stoploss at (entry + n × ATR).
- Signals trigger TradingView alerts, which can notify a user or send a webhook to a broker/automation tool.
- Visual buy/sell markers and fast/slow EMA lines are always plotted on the chart.
- No additional discretionary filters—process is fully mechanical and rule-based for both entry and exit.
***
### Summary Table
| Component | Method/Setting |
|--------------------|------------------------------------------------|
| Signal Type | EMA(5/30) crossover |
| Stoploss | ATR x custom multiplier, adaptive |
| Alerts | Automated, via TradingView alertcondition |
| Trade Management | Entry on crossover, exit on stoploss or reverse|
| Style | Short-term momentum, rule-based |
| Customization | Periods, ATR factor, alerts enabled/disabled |
***
**This approach is well-suited for fast, repeatable execution and objective analysis, minimizing emotional errors and maximizing clarity and speed of signal delivery.
***
### Trading Style
- **Strategy Base:** Uses exponential moving averages (EMA) as the core technical indicator, specifically a 5-period and a 30-period EMA for primary market structure and trend detection.
- **Trade Signals:** Buy signals are generated when the short EMA (5) crosses above the long EMA (30), and sell signals occur when the short EMA crosses below the long EMA.
- **Automation & Alerts:** The process is made actionable via `alertcondition()` in Pine Script, allowing the use of TradingView automation or webhook connections, enabling both notifications and the potential for algo/bot execution of trades.
- **Visual Feedback:** Signal points are highlighted on the chart with shapes/labels, ensuring that each entry and exit is immediately visible and easy to verify visually.
- **Risk & Stop Filtering:** Instead of a fixed-point or percent stoploss, your scripts use a volatility-adaptive stoploss based on the Average True Range (ATR), which is multiplied by a user-defined factor (for example, 2x ATR below/above entry) to create a dynamic, context-aware stop filter.
- **Customizability:** The length of EMAs and ATR period, as well as stoploss multipliers, are adjustable, making the system flexible for tuning to different markets and timeframes.
***
### Trading Process
- At every new bar, calculate the 5-EMA, 30-EMA, and ATR.
- If a crossover event occurs:
- **Buy Entry:** 5-EMA crosses above 30-EMA; script enters long and places a stoploss at (entry − n × ATR).
- **Sell Entry:** 5-EMA crosses below 30-EMA; script enters short and places a stoploss at (entry + n × ATR).
- Signals trigger TradingView alerts, which can notify a user or send a webhook to a broker/automation tool.
- Visual buy/sell markers and fast/slow EMA lines are always plotted on the chart.
- No additional discretionary filters—process is fully mechanical and rule-based for both entry and exit.
***
### Summary Table
| Component | Method/Setting |
|--------------------|------------------------------------------------|
| Signal Type | EMA(5/30) crossover |
| Stoploss | ATR x custom multiplier, adaptive |
| Alerts | Automated, via TradingView alertcondition |
| Trade Management | Entry on crossover, exit on stoploss or reverse|
| Style | Short-term momentum, rule-based |
| Customization | Periods, ATR factor, alerts enabled/disabled |
***
**This approach is well-suited for fast, repeatable execution and objective analysis, minimizing emotional errors and maximizing clarity and speed of signal delivery.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.