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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.