OPEN-SOURCE SCRIPT

Dynamic Ratchet Trend Strategy [VIX Filter]

32
Overview This strategy is a long-only trend-following system designed to capture major market moves while strictly managing downside risk through a state-machine based "Ratchet" exit logic. It incorporates a volatility filter using the CBOE VIX index to stay out of (or exit) the market during high-stress environments.

Key Features

1. Multi-Condition Entries The strategy looks for momentum shifts and trend breakouts using four Simple Moving Averages (25, 50, 100, 200).

Momentum Cross: SMA 25 crossover above SMA 50.

Trend Breakouts: A specific "3-Bar Breakout" logic above the SMA 50, 100, or 200. This requires the price to hold above the SMA for 3 consecutive bars after being below it, reducing false signals compared to simple closes.

2. VIX Volatility Filter Before entering any trade, the script checks the CBOE:VIX.

Filter: If VIX is above the threshold (default 32), new entries are blocked.

Panic Exit: If you are in a position and the VIX spikes above the threshold, the strategy executes an immediate "Panic Exit" to preserve capital during market crashes.

3. The "Ratchet" Exit System (3 Stages) Unlike a standard trailing stop, this strategy uses a 3-stage dynamic exit mechanism that tightens as profits grow:

Stage 0 (Initial Risk): Standard percentage-based Stop Loss from the entry price.

Stage 1 (The Lock-In): Triggered when profit hits 10% (configurable).

Unique Logic: Instead of trailing from the highest high, the stop is calculated based on the price at the exact moment this stage was triggered. It "steps up" once and holds, securing the initial move without being prematurely stopped out by normal volatility.

Stage 2 (Trailing Mode): Triggered when profit hits 15% (configurable).

The strategy switches to a classic Trailing Stop, following the percentage distance from the Highest High.

4. Emergency Backup A "Dead Cross" (SMA 25 crossing under SMA 50) acts as a final fail-safe to close positions if the trend reverses completely before hitting a stop.

Settings & Inputs

SMAs: Customize the lengths for all four moving averages.

VIX Filter: Toggle the filter on/off and set the panic threshold.

Exit Logic: Fully customizable percentages for Initial SL, Stage 1 Trigger/Distance, and Stage 2 Trigger/Trailing Distance.

Disclaimer This script is for educational purposes only. Past performance is not indicative of future results. Always manage your risk appropriately.

免責事項

この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。