OPEN-SOURCE SCRIPT
ID004 VIX Fear Timing Indicator

A volatility-aware staged dip-recovery indicator designed to help traders study pullback recovery conditions using price action, staged DCA logic, higher-timeframe context, and VIX fear timing.
---------------------------------------------------------------------------------------------------
## 1. [Must read as user] What this indicator is for 🧭
---------------------------------------------------------------------------------------------------
This indicator is designed to help traders study possible recovery zones after a meaningful market pullback. It does not try to buy every dip or react to every red candle. Instead, it waits for a more structured recovery setup where price has already dropped, then begins to show signs that downside pressure may be weakening.
The main idea is to help the user avoid random dip-buying. A market can look cheap and still continue falling. For that reason, the indicator checks price recovery behavior, market structure, and VIX fear conditions before showing staged labels.
This indicator should be used as a decision-support tool. It does not replace your own analysis, risk management, or trade plan.
---------------------------------------------------------------------------------------------------
## 2. [Must read as user] What the labels mean 🏷️
---------------------------------------------------------------------------------------------------
The indicator shows three staged recovery labels on the chart:
These labels are not automatic trade instructions. They are visual signals for chart review. A label means the script found a specific recovery condition, but it does not mean the trade is guaranteed to work.
The DCA stages are not random extra buy signals. They belong to one structured sequence. DCA1 only matters after Buy. DCA2 only matters after Buy and DCA1.
---------------------------------------------------------------------------------------------------
## 3. [Must read as user] Simple workflow for using it ✅
---------------------------------------------------------------------------------------------------
A practical way to use the indicator:
This tool is usually easier to interpret on cleaner timeframes such as 1 hour, 4 hours, or 1 day. Very short timeframes can create more noise, especially during fast selloffs.
Before using staged entries, decide your maximum exposure, invalidation level, stop logic, profit-taking plan, and exit conditions.
---------------------------------------------------------------------------------------------------
## 4. [Must read as user] How to read VIX fear timing 🌡️
---------------------------------------------------------------------------------------------------
VIX is used as a market fear and volatility filter. The indicator does not only ask whether price has dropped. It also asks whether fear is elevated and whether fear may be starting to cool.
A high VIX condition does not automatically mean price will recover. It only means fear or volatility stress is elevated. Price still needs to show recovery behavior before the script can confirm a staged label.
The VIX logic is different for each stage:
This helps reduce the risk of adding too early while panic is still expanding.
---------------------------------------------------------------------------------------------------
## 5. [Must read as user] Risk notes and correct expectations ⚠️
---------------------------------------------------------------------------------------------------
This indicator is not financial advice and does not guarantee future results. It does not open trades, close trades, manage stops, calculate position size, or decide how much money to risk.
DCA can increase losses if price continues falling. Every staged entry should be planned before the first signal appears. Do not use DCA1 or DCA2 only because a label appears. Use them only if the broader setup still fits your own risk plan.
Important user reminders:
---------------------------------------------------------------------------------------------------
## 6. [Optional technical explanation] Script structure and originality
---------------------------------------------------------------------------------------------------
Pine Script®
---------------------------------------------------------------------------------------------------
## 7. [Optional technical explanation] Buy stage calculation
---------------------------------------------------------------------------------------------------
Pine Script®
---------------------------------------------------------------------------------------------------
## 8. [Optional technical explanation] DCA1 and DCA2 calculation
---------------------------------------------------------------------------------------------------
Pine Script®
---------------------------------------------------------------------------------------------------
## 9. [Optional technical explanation] VIX, timeframe, and regime filters
---------------------------------------------------------------------------------------------------
Pine Script®
---------------------------------------------------------------------------------------------------
## 10. [Optional technical explanation] Inputs, alerts, background, and resets
---------------------------------------------------------------------------------------------------
Pine Script®
---------------------------------------------------------------------------------------------------
## 1. [Must read as user] What this indicator is for 🧭
---------------------------------------------------------------------------------------------------
This indicator is designed to help traders study possible recovery zones after a meaningful market pullback. It does not try to buy every dip or react to every red candle. Instead, it waits for a more structured recovery setup where price has already dropped, then begins to show signs that downside pressure may be weakening.
The main idea is to help the user avoid random dip-buying. A market can look cheap and still continue falling. For that reason, the indicator checks price recovery behavior, market structure, and VIX fear conditions before showing staged labels.
The goal is not to catch the exact bottom. The goal is to identify structured recovery attempts after fear, weakness, or volatility stress has already appeared.
This indicator should be used as a decision-support tool. It does not replace your own analysis, risk management, or trade plan.
---------------------------------------------------------------------------------------------------
## 2. [Must read as user] What the labels mean 🏷️
---------------------------------------------------------------------------------------------------
The indicator shows three staged recovery labels on the chart:
- Buy: the first recovery stage after price has made a meaningful pullback.
- DCA1: the first deeper recovery stage after a Buy label has already appeared.
- DCA2: the final deeper recovery stage after Buy and DCA1 have already appeared.
These labels are not automatic trade instructions. They are visual signals for chart review. A label means the script found a specific recovery condition, but it does not mean the trade is guaranteed to work.
The DCA stages are not random extra buy signals. They belong to one structured sequence. DCA1 only matters after Buy. DCA2 only matters after Buy and DCA1.
Read the labels as staged recovery information, not as a complete trading system.
---------------------------------------------------------------------------------------------------
## 3. [Must read as user] Simple workflow for using it ✅
---------------------------------------------------------------------------------------------------
A practical way to use the indicator:
- Start with the default settings.
- Use standard candlestick or OHLC charts.
- Wait for a Buy label before thinking about DCA1 or DCA2.
- Use DCA1 only if it appears after Buy and still fits your risk plan.
- Use DCA2 only if it appears after Buy and DCA1, especially when VIX fear has started to cool.
- Use alerts as reminders to review the chart, not as automatic trade commands.
- Check trend, support, resistance, volume, liquidity, earnings, news, macro events, and broader market risk before acting.
This tool is usually easier to interpret on cleaner timeframes such as 1 hour, 4 hours, or 1 day. Very short timeframes can create more noise, especially during fast selloffs.
Before using staged entries, decide your maximum exposure, invalidation level, stop logic, profit-taking plan, and exit conditions.
---------------------------------------------------------------------------------------------------
## 4. [Must read as user] How to read VIX fear timing 🌡️
---------------------------------------------------------------------------------------------------
VIX is used as a market fear and volatility filter. The indicator does not only ask whether price has dropped. It also asks whether fear is elevated and whether fear may be starting to cool.
A high VIX condition does not automatically mean price will recover. It only means fear or volatility stress is elevated. Price still needs to show recovery behavior before the script can confirm a staged label.
The VIX logic is different for each stage:
- Buy can appear when price recovery and VIX stress conditions are acceptable.
- DCA1 needs stricter fear confirmation when the VIX filter is active.
- DCA2 is more selective and looks for VIX to have been very high recently, then cool lower.
This helps reduce the risk of adding too early while panic is still expanding.
---------------------------------------------------------------------------------------------------
## 5. [Must read as user] Risk notes and correct expectations ⚠️
---------------------------------------------------------------------------------------------------
This indicator is not financial advice and does not guarantee future results. It does not open trades, close trades, manage stops, calculate position size, or decide how much money to risk.
DCA can increase losses if price continues falling. Every staged entry should be planned before the first signal appears. Do not use DCA1 or DCA2 only because a label appears. Use them only if the broader setup still fits your own risk plan.
Important user reminders:
- A Buy label is not proof that the bottom is in.
- DCA1 and DCA2 increase exposure and risk.
- High VIX can mean opportunity, but it can also mean danger.
- Alerts are review reminders, not trading instructions.
- Synthetic chart types may distort OHLC behavior and can make signals less reliable.
Use the indicator to organize your chart review. Do not use it as a substitute for risk management.
---------------------------------------------------------------------------------------------------
## 6. [Optional technical explanation] Script structure and originality
---------------------------------------------------------------------------------------------------
This script is an overlay indicator, not a strategy.
It uses:
* indicator(..., overlay=true)
* plotshape() for Buy, DCA1, and DCA2 labels
* bgcolor() for VIX percentile background
* alertcondition() for monitoring alerts
It does not use:
* strategy.entry()
* strategy.exit()
* strategy.close()
* automated order placement
* position management logic
The originality of the script is in how the components are connected. The script does not simply display RSI, Bollinger Bands, MACD, VIX, and moving averages as separate tools. Instead, those components are used inside a staged recovery framework.
The integration works through:
1. A state machine that controls the sequence.
2. Price-drop requirements before a stage can qualify.
3. Recovery confirmation after weakness appears.
4. Quality scores that combine several technical clues.
5. Higher-timeframe danger filters.
6. Crash filters to avoid fast breakdowns.
7. VIX fear filters that change by stage.
8. Adaptive timing windows for DCA1 and DCA2.
9. Armed-zone logic before DCA confirmation.
10. Reset logic so old stages do not stay active forever.
The state model is central:
state = 0 means no active sequence.
state = 1 means Buy has triggered.
state = 2 means DCA1 has triggered.
state = 3 means DCA2 has triggered.
This is why DCA labels cannot appear randomly. DCA1 requires Buy first. DCA2 requires DCA1 first.
The script stores important stage references:
buyPrice
d1Price
d2Price
buyBar
d1Bar
d2Bar
These values are then used to calculate deeper zones, timing windows, basket average, and reset conditions.
---------------------------------------------------------------------------------------------------
## 7. [Optional technical explanation] Buy stage calculation
---------------------------------------------------------------------------------------------------
The Buy stage is the first recovery stage. It requires a meaningful pullback and early recovery evidence.
The script calculates a recent lookback high:
lookbackHigh = ta.highest(high, lookbackBars)
Then it calculates the percentage drop from that high:
dropFromLookbackHighPct = (lookbackHigh - close) / lookbackHigh * 100
The Buy drop threshold is adjusted by the selected Signal preset:
Aggressive = lower required drop
Balanced = default required drop
Conservative = higher required drop
The effective Buy drop is:
effBuyDropPct = buyDropPct * dropMult
The core Buy setup uses:
meaningfulDrop
wasOversold
momentumRecovery
priceRecovery
meaningfulDrop:
Price must fall enough from the recent lookback high.
wasOversold:
The script checks whether RSI was recently weak:
ta.lowest(rsi, 10) < 35
momentumRecovery:
The script checks whether RSI is improving and recovering from weak conditions.
priceRecovery:
The script checks whether price is showing local recovery by closing above the fast EMA or above the previous bar high.
The script also builds a Buy quality score. The score can include:
* meaningful drop
* recent oversold behavior
* RSI improvement
* price recovery
* oversold reclaim
* Bollinger Band reclaim
* support reclaim
* bullish divergence
* strong lower wick
* MACD histogram improvement
* structure shift
* volume confirmation
* strong VIX stress
* rare VIX event
* VIX fear cooling
The final Buy signal requires all major gates:
state == 0
cooldownOk
buyRegimeOk
crashOk
vixBuyOk
buySetup
buyQualityOk
This means Buy is more selective than a simple RSI oversold label. It needs price weakness first, then recovery behavior, then context and quality confirmation.
---------------------------------------------------------------------------------------------------
## 8. [Optional technical explanation] DCA1 and DCA2 calculation
---------------------------------------------------------------------------------------------------
DCA1 and DCA2 are staged deeper recovery zones. They depend on previously stored stage prices.
DCA1 uses the Buy price:
d1ZonePct = buyPrice * (1.0 - effD1DropPct / 100.0)
DCA2 uses the DCA1 price:
d2ZonePct = d1Price * (1.0 - effD2DropPct / 100.0)
In this version, the internal drop validation is set to "Percent only", so percentage-based validation is the active method.
DCA1 logic:
DCA1 requires state == 1.
This means Buy must already exist.
DCA1 must happen inside its timing window:
barsSinceBuy >= adaptiveD1Min
barsSinceBuy <= adaptiveD1Max
The DCA1 zone becomes armed when:
* state is 1
* price is below the Buy price
* price reaches the DCA1 zone
* the DCA1 timing window is valid
After the zone is armed, the script waits for a confirmation delay:
d1ConfirmDelay
DCA1 technical confirmation can come from:
B1 = bullish divergence and RSI improvement
B2 = Bollinger Band reclaim plus wick, candle, or MACD improvement
B3 = support reclaim or strong lower wick plus RSI or volume confirmation
Bscore = weighted recovery score
DCA1 also uses VIX score components:
* basic VIX stress
* strong VIX stress
* rare VIX event
* VIX fear cooling
The final DCA1 signal requires:
state == 1
d1Armed
d1ArmedLongEnough
inD1Window
recoveryCandleD1
dcaRegimeOk
crashOk
d1VixOk
d1TechnicalOk
d1QualityOk
DCA2 logic:
DCA2 requires state == 2.
This means Buy and DCA1 must already exist.
DCA2 must happen inside its timing window:
barsSinceD1 >= adaptiveD2Min
barsSinceD1 <= adaptiveD2Max
DCA2 also checks price against basket average:
basketAvg = average of active staged prices
The DCA2 zone becomes armed when:
* state is 2
* price reaches the DCA2 zone
* price is below basket average
* the DCA2 timing window is valid
DCA2 technical confirmation is stricter and can include:
C1 = higher-timeframe RSI or MACD improvement plus local recovery
C2 = capitulation-style volume spike, strong lower wick, and large range
C3 = structure shift plus RSI improvement
Cscore = weighted score using higher-timeframe improvement, capitulation evidence, structure shift, wick rejection, bullish engulfing, volume spike, and higher-timeframe MACD improvement
The final DCA2 signal requires:
state == 2
d2Armed
d2ArmedLongEnough
inD2Window
recoveryCandleD2
dcaRegimeOk
crashOk
d2VixOk
d2TechnicalOk
d2QualityOk
This explains why DCA1 and DCA2 are not only lower-price signals. A zone must be reached first, then recovery evidence must appear before confirmation.
---------------------------------------------------------------------------------------------------
## 9. [Optional technical explanation] VIX, timeframe, and regime filters
---------------------------------------------------------------------------------------------------
The script requests VIX data from the selected VIX symbol:
vixSymbol = input.symbol("CBOE:VIX", "VIX symbol")
VIX uses the active chart timeframe:
vixTf = timeframe.period
The VIX function returns:
* VIX close
* VIX percentile
* VIX percentile jump
* whether VIX is falling
* whether VIX percentile is falling
The script builds several VIX conditions:
vixAbsoluteOk:
VIX close is above an internal stress level.
vixHighPercentileOk:
VIX percentile is above the selected stress percentile.
vixJumpOk:
VIX percentile jumped sharply.
vixRareEvent:
VIX percentile or absolute VIX level is extremely high.
vixStressBasic:
Basic fear condition is active.
vixStressStrong:
Stronger fear condition is active.
vixFearCooling:
Fear is elevated and VIX or VIX percentile is falling.
For DCA2, the script uses a special cooling model:
vixRecentPeakPercentile = recent highest VIX percentile
vixWasTooHighRecently = VIX percentile was very high recently
vixCooledFromPeak = VIX percentile cooled by the selected cooling amount
vixCoolingButStillElevated = VIX is still high but falling
DCA2 can pass VIX cooling when:
* VIX cooled enough from a recent high peak
* a rare VIX event is active and fear is cooling
* VIX is still elevated but percentile is falling
The stage-specific VIX design is important:
Buy can use basic VIX stress or fear cooling.
DCA1 requires stricter stress confirmation.
DCA2 requires recent high fear followed by cooling.
The script also adapts to chart profiles:
15 minutes
30 minutes
1 hour
4 hours
1 day
The profile affects:
* price lookback
* VIX lookback
* DCA timing windows
* confirmation delays
* higher-timeframe reference
* crash detection window
Higher-timeframe regime logic checks:
* higher-timeframe close
* higher-timeframe EMA 50
* higher-timeframe EMA 200
* higher-timeframe RSI
* higher-timeframe RSI direction
* higher-timeframe MACD histogram improvement
The danger regime blocks normal recovery signals when higher-timeframe trend and momentum are too weak, unless rare fear and local recovery behavior justify an exception.
The crash filter checks for fast, high-volume selloffs and helps avoid triggering recovery labels during active breakdown pressure.
---------------------------------------------------------------------------------------------------
## 10. [Optional technical explanation] Inputs, alerts, background, and resets
---------------------------------------------------------------------------------------------------
The script uses 10 visible inputs to keep the user interface focused:
1. Signal preset
Controls strictness:
Aggressive, Balanced, Conservative
2. Buy drop from recent high %
Controls the minimum pullback before Buy can qualify.
3. DCA1 drop below Buy %
Controls how far price must move below Buy before DCA1 can arm.
4. DCA2 drop below DCA1 %
Controls how far price must move below DCA1 before DCA2 can arm.
5. Rejection wick %
Controls the minimum lower-wick rejection requirement.
6. VIX mode
Off, Conservative, Very Strict
7. VIX symbol
Default VIX source is CBOE:VIX.
8. VIX stress percentile
Main percentile threshold for elevated fear.
9. DCA2 VIX cooling drop
Required cooling from the recent VIX percentile peak.
10. Low VIX color percentile
Defines unusually low VIX percentile conditions.
Hidden internal defaults include:
* RSI length
* fast EMA length
* ATR length
* Bollinger Band length and multiplier
* volume average length
* swing length
* cooldown bars
* profile-based lookbacks
* adaptive timing sample rules
* VIX rare-event thresholds
* VIX background transparency
* reset timing
Alerts:
The script includes seven alert conditions:
1. Buy confirmed
2. DCA1 zone armed
3. DCA1 confirmed
4. DCA2 zone armed
5. DCA2 confirmed
6. VIX cooled after high
7. VIX too low percentile
Alert meaning:
* Armed alerts mean price reached a DCA zone, but confirmation is not complete.
* Confirmed alerts mean the full stage logic is complete.
* VIX alerts describe fear-regime behavior.
Background:
The script calculates high and low VIX percentile background conditions. In the current plotted version, the visible green background marks very high VIX percentile. This means elevated fear or volatility stress, not automatic bullishness.
Reset logic:
The script resets the active sequence when:
* DCA2 has completed and enough bars have passed.
* DCA1 did not appear inside the valid window after Buy.
* DCA2 did not appear inside the valid window after DCA1.
This prevents old signals from staying active forever and helps each staged sequence remain connected to the original recovery setup.
Publication note:
This description is written so users can understand the script without reading Pine code. It explains what the script does, why the components are combined, how the staged logic works, and how traders can use it responsibly.
Open-source transparency note: if any external open-source code, function, or logic was reused, the original author and source should be credited clearly in the publication.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.