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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。