Take the square root of the selected value (lowest and or highest point).
Add (for up or subtract for down) 0.25 for every 45 degrees of rotation to the desired calculation.
Square this. Round to two decimal places.
For example: $65,000 will be scaled down to 650 for Gann calculations, and then the outputs will be rescaled (multiplied by 100 in this instance) before being drawn on the chart.
- Take the logarithm of the highest price visible on the chart. Divide this by the logarithm of 10 and subtract 3, stopping at 0. This gives the scaling magnitude.
magnitude = math.max(0, math.ceil(math.log(high_vis) / math.log(10)) - 3)- Divide the highest (or lowest) visible price on the chart by 10 raised to magnitude (10^magnitude).
high_vis / math.pow(10, magnitude)
low_vis / math.pow(10, magnitude)- Perform regular Gann calculations with these as the high and low inputs (see indicator description above for details).
- Scale up the Gann calculation outputs by multiplying by10^magnitude and draw to chart.
gann * math.pow(10, magnitude)
Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.