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.
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?
//@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)