1️⃣ ATR is calculated based on the chosen period (default 14) to determine volatility. 2️⃣ When the price crosses above the SMA(14), a Long stop-loss is set. The stop-loss is placed below the current price at a distance of 1.5 × ATR (default). The green line appears below the candle. 3️⃣ When the price crosses below the SMA(14), a Short stop-loss is set. The stop-loss is placed above the current price at a distance of 1.5 × ATR. The red line appears above the candle.
🔹 Examples of Manifestation on the Chart 📌 Scenario 1: Bullish Trend → Long Stop-Loss is Activated ✅ If the price rises above the SMA(14), a green stop-loss is set below the price. ✅ The stop-loss remains fixed until the price makes a new crossover.
🔴 If the price drops and hits the green line, the Long position is closed.
📌 Scenario 2: Bearish Trend → Short Stop-Loss is Activated ✅ If the price falls below the SMA(14), a red stop-loss is set above the price. ✅ The stop-loss remains in place until a new cross below the SMA(14).
🟢 If the price rises and hits the red line, the Short position is closed.
🔹 Strengths and Limitations of the Code ✅ Advantages:
Automatically adapts to market volatility. Works on any timeframe and instrument. Provides a dynamic stop-loss based on real conditions. ❌ Limitations:
Does not adjust the stop-loss after each candle (it is not a trailing stop). The stop-loss remains fixed until a new crossover/crossunder of the price over the SMA(14). Does not provide entry signals, only position protection.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publications is governed by House rules. คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้