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.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.