twobiscuitsngravy

Trading Range Finder

twobiscuitsngravy Güncellendi   
There are 5 horizontal lines printed by this indicator, and they extend from the last bar to a user-defined look-back period (the number of bars back from the last bar). The dark blue lines are the swing high and swing low within the look-back period. The magenta lines are the range high and range low used to define a trading range for the look-back period. The light blue line in the middle is the halfway point within the trading range, or the equilibrium.

The majority of the script logic focuses on the placement of the magenta lines (range high and range low). To do this, a histogram analysis is used. The price difference between the swing high and swing low is broken up into discrete bins which are monitored by an array. The high and low of each bar within the look-back period is used to populate the bins. There is also a toggle to use the midpoint of each bar to populate the bins as well. This means that for every bar two bins (three with the toggle) within the array will increase by a value of 1. The two bins with the highest count are used to print the magenta lines. Around each magenta line are two dotted lines and a shaded area to show the size of the bins used in the analysis.

Regarding bin size:
The bin size is a fraction of the asset price. If the price difference between the swing high and swing low is $1000, and the bin size is 1, then there are 1000 bins. I initially made the bin size a user input, but for a given look-back period the trading range would have wildly different range highs/lows when the bin size was incremented by small amounts. It was also difficult to manage a user input when the asset price is near, or less than 1. I then used a loop to optimize the bin size so it is no longer a user input. The optimization parameter is the maximization of the distance between the range high and range low. I capped the bin size within the script somewhat arbitrarily (but with a lot of testing) at ((swing high - swing low)/50) because sometimes very large bin sizes (one third or one quarter of the difference between swing high and swing low) would maximize the distance between the range high and range low, but with the line placed in the middle of the bin, its level wouldn't always make sense. Besides the maximum bin size, the only other hardcoded part of the script was to test 50 bin sizes, up to and including the maximum bin size. The loop finds the bin size that gives the largest separation between prices, and then uses that bin size to set the up the array with the bin counts.

Toggles for the plots are available to show how the range high, range low, and equilibrium move as new bars are added to the chart. The effects of these plots can most readily be seen in replay mode. There is also to a toggle to show the Fibonacci levels between the range high and range low. I made the midpoint a toggle because sometimes it is detrimental, meaning it contracts the trading range to the point of not being useful on a given chart. If there are periods of very low volatility and the bin size is large enough, the midpoint might end up in the same bin as the high or the low (or both!), and a single bar could unevenly weight a particular bin. The midpoint toggle, along with different lookback periods, will be needed to find a suitable trading range for a given chart.
Sürüm Notları:
There are 5 horizontal lines printed by this indicator, and they extend from the last bar to a user-defined look-back period (the number of bars back from the last bar). The dark blue lines are the swing high and swing low within the look-back period. The magenta lines are the range high and range low used to define a trading range for the look-back period. The light blue line in the middle is the halfway point within the trading range, or the equilibrium.

The majority of the script logic focuses on the placement of the magenta lines (range high and range low). To do this, a histogram analysis is used. The price difference between the swing high and swing low is broken up into discrete bins which are monitored by an array. The high and low of each bar within the look-back period is used to populate the bins. There are also toggles to use the midpoint, and the ¼ and ¾ points of each bar to populate the bins as well. This means that for every bar two bins (three to five with the toggles) within the array will increase by a value of 1. The two bins with the highest count are used to print the magenta lines. Around each magenta line are two dotted lines and a shaded area to show the size of the bins used in the analysis.

Regarding bin size:
The bin size is a fraction of the asset price. If the price difference between the swing high and swing low is $1000, and the bin size is 1, then there are 1000 bins. I initially made the bin size a user input, but for a given look-back period the trading range would have wildly different range highs/lows when the bin size was incremented by small amounts. It was also difficult to manage a user input when the asset price is near, or less than 1. I then used a loop to optimize the bin size so it is no longer a user input. The optimization parameter is the maximization of the distance between the range high and range low. I capped the bin size within the script somewhat arbitrarily (but with a lot of testing) at ((swing high - swing low)/50) because sometimes very large bin sizes (one third or one quarter of the difference between swing high and swing low) would maximize the distance between the range high and range low, but with the line placed in the middle of the bin, its level wouldn't always make sense. Besides the maximum bin size, the only other hardcoded part of the script was to test 50 bin sizes, up to and including the maximum bin size. The loop finds the bin size that gives the largest separation between prices, and then uses that bin size to set the up the array with the bin counts.

Toggles for the plots are available to show how the range high, range low, and equilibrium move as new bars are added to the chart. The effects of these plots can most readily be seen in replay mode. There is also to a toggle to show the Fibonacci levels between the range high and range low. I made toggles for use of the midpoint, ¼ point, and ¾ point of each bar in the analysis because sometimes they are detrimental, meaning they contract the trading range to the point of not being useful on a given chart. If there are periods of very low volatility and the bin size is large enough, the midpoint and quarter-points might end up in the same bin as the high or the low (or both!), and a single bar could unevenly weight a particular bin. The midpoint and quarter-point toggles, along with different lookback periods, will be needed to find a suitable trading range for a given chart.
Yalnızca davetli komut dosyası

Bu komut dosyasına erişim, yazar tarafından yetkilendirilen kullanıcılarla sınırlıdır ve genellikle ödeme gerektirir. Sık kullanılanlarınıza ekleyebilirsiniz, ancak bunu yalnızca izin talep edip yazarından bu izni aldıktan sonra kullanabileceksiniz. Daha fazla bilgi için twobiscuitsngravy ile iletişime geçin veya yazarın aşağıdaki talimatlarını izleyin.

TradingView, yazarına % 100 güvenip komut dosyasının nasıl çalıştığını anlayana kadar bir komut dosyası için ödeme yapmamanızı ve onu kullanmamanızı önerir. Çoğu durumda, Topluluk Kütüphanemizde ücretsiz olarak iyi bir açık kaynak alternatifi bulabilirsiniz.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.

Yazarın talimatları

I've done a lot of testing but it's still a work in progress. I'm publishing it mainly to share with friends, but if you're interested in using it, let me know.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?

Hatırlatma: erişim istemeden önce lütfen okuyun.