Koalems

Percentage of direction alternation

This is just an idea I had and I have no idea whether it will be useful but I thought I would “toss it out into the wild” because if someone finds it of benefit then all the better.

How it works is really simple. It looks at a number of bars/candles back and if two bars next two each other close where one is higher than its open and the other closes lower (a bullish and bearish candle next to each other) then it adds one to the count of alternations. So, if you are looking 10 (adjustable of course) bars back then you can have 9 compares (number of bars subtract one).

If all nine compares are opposite closes of each other then you get a 100% alternation.

I’m not sure if this is useful for anyone but my original thought was the more alternation the more likely you are in ranging and the less you should consider entering a trade or the more you should consider exiting a trade. It might also reflect choppiness to some extent as well.

I also noticed in a couple of spots when I was looking at the results that good trends came just after the alternation peaked around 100% so it might be a bit of an indicator to enter a trade before the move happens.


It shows the alternation percentage but also the “weighted alternation” percentage which I think looks more useful as it give more credence to the alternations closer the live trading.

For visual usefulness you can invert the output so that maximum alternation is 0 instead of 100.

I’ve set it up as being displayed as area but as normal lines is also good.


Let me know if you find a way that it shows something useful for entering or exiting your trades. The more feedback I get the more I’ll throw my crazy notions out there!


The code is structured to easily drop into a bigger system so use it as a lone indicator or add the code to some bigger project you are creating. If you do integrate it into something else then send me a note as it would be nice to know it's being well used.

Enjoy and good luck!
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?