OPEN-SOURCE SCRIPT
Breakdown or Buyable Dip? Pullback Depth Can Help

As a common adage says, “the market doesn’t move in a straight line.” But when prices have fallen, it’s not always clear whether buying makes sense. That’s where today’s script may help.
Most traditional indicators judge movement based on price. That’s obviously important, but time can also be helpful. After all, there’s a big difference between probing a low from 2-3 weeks ago versus a low from months or even years in the past.
Pullback Depth clearly illustrates this by answering the question: “Today’s low is the lowest in how many bars?”
The resulting integer is plotted in a simple histogram. Values are always negative because bars with higher absolute values (meaning more negative, or further below zero) are potentially more bearish.

The study also has a maximum lookback period to avoid overwhelming the study with too many bars. Its default setting of 125 bars includes enough history to illustrate the trend.
The stock market’s recent run has seen only shallow pullbacks. Most dips have probed 1-2 weeks in the past, while Friday’s selloff only turned back the clock a month.
Consider two other previous moments.
First, the great bull run of 1995 saw only shallow pullbacks. (None exceeded 50 days.):

In contrast, early 2022 saw the S&P 500 test levels more than 100 candles into the past. It soon fell into an official “bear market:”

TradeStation has, for decades, advanced the trading industry, providing access to stocks, options and futures. If you're born to trade, we could be for you. See our Overview for more.
Past performance, whether actual or indicated by historical tests of strategies, is no guarantee of future performance or success. There is a possibility that you may sustain a loss equal to or greater than your entire investment regardless of which asset class you trade (equities, options or futures); therefore, you should not invest or risk money that you cannot afford to lose. Online trading is not suitable for all investors. View the document titled Characteristics and Risks of Standardized Options at https://www.TradeStation.com/DisclosureOptions. Before trading any asset class, customers must read the relevant risk disclosure statements on https://www.TradeStation.com/Important-Information/. System access and trade placement and execution may be delayed or fail due to market volatility and volume, quote delays, system and software errors, Internet traffic, outages and other factors.
Securities and futures trading is offered to self-directed customers by TradeStation Securities, Inc., a broker-dealer registered with the Securities and Exchange Commission and a futures commission merchant licensed with the Commodity Futures Trading Commission). TradeStation Securities is a member of the Financial Industry Regulatory Authority, the National Futures Association, and a number of exchanges.
TradeStation Securities, Inc. and TradeStation Technologies, Inc. are each wholly owned subsidiaries of TradeStation Group, Inc., both operating, and providing products and services, under the TradeStation brand and trademark. When applying for, or purchasing, accounts, subscriptions, products and services, it is important that you know which company you will be dealing with. Visit https://www.TradeStation.com/DisclosureTSCompanies for further important information explaining what this means.
Most traditional indicators judge movement based on price. That’s obviously important, but time can also be helpful. After all, there’s a big difference between probing a low from 2-3 weeks ago versus a low from months or even years in the past.
Pullback Depth clearly illustrates this by answering the question: “Today’s low is the lowest in how many bars?”
The resulting integer is plotted in a simple histogram. Values are always negative because bars with higher absolute values (meaning more negative, or further below zero) are potentially more bearish.
The study also has a maximum lookback period to avoid overwhelming the study with too many bars. Its default setting of 125 bars includes enough history to illustrate the trend.
The stock market’s recent run has seen only shallow pullbacks. Most dips have probed 1-2 weeks in the past, while Friday’s selloff only turned back the clock a month.
Consider two other previous moments.
First, the great bull run of 1995 saw only shallow pullbacks. (None exceeded 50 days.):
In contrast, early 2022 saw the S&P 500 test levels more than 100 candles into the past. It soon fell into an official “bear market:”
TradeStation has, for decades, advanced the trading industry, providing access to stocks, options and futures. If you're born to trade, we could be for you. See our Overview for more.
Past performance, whether actual or indicated by historical tests of strategies, is no guarantee of future performance or success. There is a possibility that you may sustain a loss equal to or greater than your entire investment regardless of which asset class you trade (equities, options or futures); therefore, you should not invest or risk money that you cannot afford to lose. Online trading is not suitable for all investors. View the document titled Characteristics and Risks of Standardized Options at https://www.TradeStation.com/DisclosureOptions. Before trading any asset class, customers must read the relevant risk disclosure statements on https://www.TradeStation.com/Important-Information/. System access and trade placement and execution may be delayed or fail due to market volatility and volume, quote delays, system and software errors, Internet traffic, outages and other factors.
Securities and futures trading is offered to self-directed customers by TradeStation Securities, Inc., a broker-dealer registered with the Securities and Exchange Commission and a futures commission merchant licensed with the Commodity Futures Trading Commission). TradeStation Securities is a member of the Financial Industry Regulatory Authority, the National Futures Association, and a number of exchanges.
TradeStation Securities, Inc. and TradeStation Technologies, Inc. are each wholly owned subsidiaries of TradeStation Group, Inc., both operating, and providing products and services, under the TradeStation brand and trademark. When applying for, or purchasing, accounts, subscriptions, products and services, it is important that you know which company you will be dealing with. Visit https://www.TradeStation.com/DisclosureTSCompanies for further important information explaining what this means.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.