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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.