OPEN-SOURCE SCRIPT
Dynamic SMA Trend System [Multi-Stage Risk Engine]

Description:
This script implements a robust Trend Following strategy based on a multiple Simple Moving Average (SMA) crossover logic (25, 50, 100, 200). What sets this strategy apart is its advanced "4-Stage Risk Engine" and a smart "High-Water Mark" Re-Entry system, designed to protect profits during parabolic moves while filtering out chop during sideways markets.
How it works:
The strategy operates on three core pillars: Trend Identification, Dynamic Risk Management, and Momentum Re-Entry.
1. Entry Logic (Trend Identification) The script looks for crossovers at different trend stages to capture early reversals as well as established trends:
Short-Term: SMA 25 crosses over SMA 50.
Mid-Term: SMA 50 crosses over SMA 100.
Macro-Trend: SMA 100 crosses over SMA 200.
2. The 4-Stage Risk Engine (Dynamic Stop Loss) Instead of a static Stop Loss, this strategy uses a progressive system that adapts as the price increases:
Stage 1 (Protection): Starts with a fixed Stop Loss (default -10%) to give the trade room to breathe.
Stage 2 (Break-Even): Once the price rises by 12%, the Stop is moved to trailing mode (10% distance), effectively securing a near break-even state.
Stage 3 (Profit Locking): At 25% profit, the trailing stop tightens to 8% to lock in gains.
Stage 4 (Parabolic Mode): At 40% profit, the trailing stop tightens further to 5% to capture the peak of parabolic moves.
3. Dual Exit Mechanism The strategy exits a position if EITHER of the following happens:
Stop Loss Hit: Price falls below the dynamic red line (Risk Engine).
Dead Cross: The trend structure breaks (e.g., SMA 25 crosses under SMA 50), signaling a momentum loss even if the Stop Loss wasn't hit.
4. "High-Water Mark" Re-Entry To avoid "whipsaws" in choppy markets, the script does not re-enter immediately after a stop-out.
It marks the highest price of the previous trade (Green Dotted Line).
A Re-Entry only occurs if the price breaks above this previous high (showing renewed strength) AND the long-term trend is bullish (Price > SMA 200).
Visuals:
SMAs: 25 (Yellow), 50 (Orange), 100 (Blue), 200 (White).
Red Line: Visualizes the dynamic Stop Loss level.
Green Dots: Visualizes the target price needed for a valid re-entry.
Settings: All parameters (SMA lengths, Stop Loss percentages, Staging triggers) are fully customizable in the settings menu to fit different assets (Crypto, Stocks, Forex) and timeframes.
This script implements a robust Trend Following strategy based on a multiple Simple Moving Average (SMA) crossover logic (25, 50, 100, 200). What sets this strategy apart is its advanced "4-Stage Risk Engine" and a smart "High-Water Mark" Re-Entry system, designed to protect profits during parabolic moves while filtering out chop during sideways markets.
How it works:
The strategy operates on three core pillars: Trend Identification, Dynamic Risk Management, and Momentum Re-Entry.
1. Entry Logic (Trend Identification) The script looks for crossovers at different trend stages to capture early reversals as well as established trends:
Short-Term: SMA 25 crosses over SMA 50.
Mid-Term: SMA 50 crosses over SMA 100.
Macro-Trend: SMA 100 crosses over SMA 200.
2. The 4-Stage Risk Engine (Dynamic Stop Loss) Instead of a static Stop Loss, this strategy uses a progressive system that adapts as the price increases:
Stage 1 (Protection): Starts with a fixed Stop Loss (default -10%) to give the trade room to breathe.
Stage 2 (Break-Even): Once the price rises by 12%, the Stop is moved to trailing mode (10% distance), effectively securing a near break-even state.
Stage 3 (Profit Locking): At 25% profit, the trailing stop tightens to 8% to lock in gains.
Stage 4 (Parabolic Mode): At 40% profit, the trailing stop tightens further to 5% to capture the peak of parabolic moves.
3. Dual Exit Mechanism The strategy exits a position if EITHER of the following happens:
Stop Loss Hit: Price falls below the dynamic red line (Risk Engine).
Dead Cross: The trend structure breaks (e.g., SMA 25 crosses under SMA 50), signaling a momentum loss even if the Stop Loss wasn't hit.
4. "High-Water Mark" Re-Entry To avoid "whipsaws" in choppy markets, the script does not re-enter immediately after a stop-out.
It marks the highest price of the previous trade (Green Dotted Line).
A Re-Entry only occurs if the price breaks above this previous high (showing renewed strength) AND the long-term trend is bullish (Price > SMA 200).
Visuals:
SMAs: 25 (Yellow), 50 (Orange), 100 (Blue), 200 (White).
Red Line: Visualizes the dynamic Stop Loss level.
Green Dots: Visualizes the target price needed for a valid re-entry.
Settings: All parameters (SMA lengths, Stop Loss percentages, Staging triggers) are fully customizable in the settings menu to fit different assets (Crypto, Stocks, Forex) and timeframes.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.