OPEN-SOURCE SCRIPT
SMA Crossover Strategy with TP/SL

📊 Strategy Description: SMA Crossover Strategy with TP/SL
This is a Simple Moving Average (SMA) Crossover Strategy designed to help traders identify trend reversals and manage trades with proper risk-reward logic.
🔹 Entry Logic:
Buy Signal: When the Fast SMA crosses above the Slow SMA → indicating a bullish trend.
Sell Signal: When the Fast SMA crosses below the Slow SMA → indicating a bearish trend.
🔹 Exit Logic:
Take Profit: The strategy exits the position when price reaches a user-defined profit target.
Stop Loss: The trade is closed if price moves against the position beyond the specified stop-loss limit.
⚙️ Parameters:
Fast SMA Length: Number of candles used for fast moving average (default: 10)
Slow SMA Length: Number of candles used for slow moving average (default: 30)
Take Profit (%): Profit target in percentage (default: 0.10%)
Stop Loss (%): Maximum allowed loss per trade (default: 0.10%)
✅ Additional Features:
Strategy backtesting supported
Visual arrows for Buy/Sell signals
Bar coloring based on trend
Alert conditions for Buy/Sell crossover signals
🧠 Suggested Use:
Works best on 1 min, 5 hour, or daily timeframes.
Can be applied to stocks, crypto, forex, or indices.
Ideal for trend-following traders who want automation with risk control.
This is a Simple Moving Average (SMA) Crossover Strategy designed to help traders identify trend reversals and manage trades with proper risk-reward logic.
🔹 Entry Logic:
Buy Signal: When the Fast SMA crosses above the Slow SMA → indicating a bullish trend.
Sell Signal: When the Fast SMA crosses below the Slow SMA → indicating a bearish trend.
🔹 Exit Logic:
Take Profit: The strategy exits the position when price reaches a user-defined profit target.
Stop Loss: The trade is closed if price moves against the position beyond the specified stop-loss limit.
⚙️ Parameters:
Fast SMA Length: Number of candles used for fast moving average (default: 10)
Slow SMA Length: Number of candles used for slow moving average (default: 30)
Take Profit (%): Profit target in percentage (default: 0.10%)
Stop Loss (%): Maximum allowed loss per trade (default: 0.10%)
✅ Additional Features:
Strategy backtesting supported
Visual arrows for Buy/Sell signals
Bar coloring based on trend
Alert conditions for Buy/Sell crossover signals
🧠 Suggested Use:
Works best on 1 min, 5 hour, or daily timeframes.
Can be applied to stocks, crypto, forex, or indices.
Ideal for trend-following traders who want automation with risk control.
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.