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.
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
//@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)