OPEN-SOURCE SCRIPT
McMillan's VIX 20/200 DMA Trend Signal (No Look-Ahead)

Key Changes Made:
Index Shifting [1]: In the low_vol_regime_cond and high_vol_regime_cond definitions, I added [1] to vix_close, vix20, and vix200. This forces the script to look at the data from the candle that just closed, rather than the data of the candle the signal is currently printing on.
Logic Logic: The regime variable now updates based on that confirmed historical data. This means the background color and the triangles will only appear on the first bar of the "new" day (or the next candle if you are on a lower timeframe) after the VIX conditions have been met and locked in.
Table Update: The info table now displays the "Last Close" values for the VIX and its MAs to reflect what is actually driving the current signal.
Index Shifting [1]: In the low_vol_regime_cond and high_vol_regime_cond definitions, I added [1] to vix_close, vix20, and vix200. This forces the script to look at the data from the candle that just closed, rather than the data of the candle the signal is currently printing on.
Logic Logic: The regime variable now updates based on that confirmed historical data. This means the background color and the triangles will only appear on the first bar of the "new" day (or the next candle if you are on a lower timeframe) after the VIX conditions have been met and locked in.
Table Update: The info table now displays the "Last Close" values for the VIX and its MAs to reflect what is actually driving the current signal.
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.