Trend Length

Script tries to capture the length of trends. It calculates an SMA and then determines the slope of the SMA using a simple momentum function. From there it counts bars from when the slope changed directions last. The lime green line is the count from when the slope changed. The yellow line is the average time of a trend. The white line is "trying" to capture the length of a full healthy pip running trend. Pick and SMA you like and then run through many currencies. I find that trends tend to be the same length. Not surprising as the markets are extremely correlated to each other. The trick is to find the most active pair for action. To do that look up my Pairs Range script.

Comments are welcome.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study("Trend Length")
l = input(defval=150,title="Length for indicator",type=integer)
a= sma(close,l)