OPEN-SOURCE SCRIPT
JWs Algo

📈 JWs Algo — 8/21 EMA Crossover Strategy with Take Profit and Stop Loss
JWs Algo is a momentum-based trading strategy that uses a classic 8/21 Exponential Moving Average (EMA) crossover to identify trend reversals and generate long and short trade signals. It includes built-in take profit and stop loss parameters to manage risk and lock in profits automatically.
🔍 Core Logic
Long Entry: When the 8 EMA crosses above the 21 EMA (bullish signal)
Short Entry: When the 8 EMA crosses below the 21 EMA (bearish signal)
Exit: Each position is exited automatically upon hitting either:
A take profit, defined as a percentage gain from entry
A stop loss, defined as a percentage loss from entry
✅ Key Features
Supports both long and short trades
Configurable take profit (%) and stop loss (%)
Prevents overlapping trades — the strategy waits for one trade to fully close before opening another
Clean visualization with:
Buy and sell signal markers
Plotted 8 EMA and 21 EMA for trend context
Compatible with any symbol and timeframe
⚙️ Recommended Use
This strategy works best on trending markets and can be adapted for:
Crypto
Forex
Stocks
Indices
Tune the TP/SL values and timeframe based on asset volatility for best results. Backtest thoroughly.
JWs Algo is a momentum-based trading strategy that uses a classic 8/21 Exponential Moving Average (EMA) crossover to identify trend reversals and generate long and short trade signals. It includes built-in take profit and stop loss parameters to manage risk and lock in profits automatically.
🔍 Core Logic
Long Entry: When the 8 EMA crosses above the 21 EMA (bullish signal)
Short Entry: When the 8 EMA crosses below the 21 EMA (bearish signal)
Exit: Each position is exited automatically upon hitting either:
A take profit, defined as a percentage gain from entry
A stop loss, defined as a percentage loss from entry
✅ Key Features
Supports both long and short trades
Configurable take profit (%) and stop loss (%)
Prevents overlapping trades — the strategy waits for one trade to fully close before opening another
Clean visualization with:
Buy and sell signal markers
Plotted 8 EMA and 21 EMA for trend context
Compatible with any symbol and timeframe
⚙️ Recommended Use
This strategy works best on trending markets and can be adapted for:
Crypto
Forex
Stocks
Indices
Tune the TP/SL values and timeframe based on asset volatility for best results. Backtest thoroughly.
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.