OPEN-SOURCE SCRIPT
MA Narrow State Scanner

This script is a technical scanner specifically designed to find stocks or assets where the short-term trend (20 MA) and the long-term trend (200 MA) have converged significantly. In Oliver Velez's trading strategy, this condition is known as a "Narrow State" and often signals an impending, explosive price move.
How the Script Works
The script calculates the percentage distance between the 20-day moving average and the 200-day moving average. It doesn't check the current live state, but specifically looks at the closing price of the previous trading day.
If the distance is below your defined threshold, the script outputs a signal ("1").
In the Pine Screener, you can use this to filter your favorites list before the market opens to instantly see which stocks closed in a "Narrow State" yesterday.
How to Set the Values
To adjust the settings, click on the indicator name on the chart and select the gear icon (Settings). In the "Inputs" tab, you will find:
Setting Default Value Description
20 MA Length 20 The period for the fast moving average (Velez standard).
200 MA Length 200 The period for the slow moving average (institutional anchor).
Narrow Threshold % 1.0 The most important value. It determines how "close" the MAs must be.
Pro-Tip for Setting the Threshold:
1.0% (Default): Very strict. Finds only stocks where the lines are almost overlapping. Ideal for blue chips like Apple or Disney.
2.0% - 3.0%: A bit looser. Well-suited for more volatile tech stocks or crypto, as these rarely reach a perfect 1% gap.
0.5%: Extremely narrow. Finds only the absolute "coiled springs" (maximum tension).
Daily Application
Open the Pine Screener (at the bottom of TradingView).
Select your Favorites List.
Filter by the indicator result Scan Signal = 1.
Any stocks that appear in the list are in a Velez-style "Narrow State" and are ready for your trading plan today.
How the Script Works
The script calculates the percentage distance between the 20-day moving average and the 200-day moving average. It doesn't check the current live state, but specifically looks at the closing price of the previous trading day.
If the distance is below your defined threshold, the script outputs a signal ("1").
In the Pine Screener, you can use this to filter your favorites list before the market opens to instantly see which stocks closed in a "Narrow State" yesterday.
How to Set the Values
To adjust the settings, click on the indicator name on the chart and select the gear icon (Settings). In the "Inputs" tab, you will find:
Setting Default Value Description
20 MA Length 20 The period for the fast moving average (Velez standard).
200 MA Length 200 The period for the slow moving average (institutional anchor).
Narrow Threshold % 1.0 The most important value. It determines how "close" the MAs must be.
Pro-Tip for Setting the Threshold:
1.0% (Default): Very strict. Finds only stocks where the lines are almost overlapping. Ideal for blue chips like Apple or Disney.
2.0% - 3.0%: A bit looser. Well-suited for more volatile tech stocks or crypto, as these rarely reach a perfect 1% gap.
0.5%: Extremely narrow. Finds only the absolute "coiled springs" (maximum tension).
Daily Application
Open the Pine Screener (at the bottom of TradingView).
Select your Favorites List.
Filter by the indicator result Scan Signal = 1.
Any stocks that appear in the list are in a Velez-style "Narrow State" and are ready for your trading plan today.
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.