forexpirate

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.
Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.

Хотите использовать этот скрипт на графике?
//@version=2
study("Trend Length")
l = input(defval=150,title="Length for indicator",type=integer)
a= sma(close,l)
am=mom(a,5)
t=round(barssince(cross(am,0)))
th=highest(t,54)
plot(t,color=lime)
plot(sma(th,1000),color=white)
plot(round(sma(t,1000)),color=yellow,linewidth=2)