XrayTrades

Dynamic Gann Levels [XrayTrades]

XrayTrades 已更新   
This indicator dynamically captures the highest and lowest points visible on the chart and calculates Gann Support and Resistance Levels. The inputs are detailed below.

Why create this indicator?
There is no other indicator with the same functionality on TradingView.
These calculations are time-consuming; the speed at which this indicator calculates any number of rotations and degrees and visually displays them on the chart is invaluable to me, and hopefully others who use/perform these calculations.

Works on any time frame:
Year, month, week, day, etc. Smaller timeframes (intraday) for higher prices may require adjusting the y-axis of the chart after the calculation of levels due to the nature of squaring numbers.

Inputs:
  • Resistance: Up (from pivot low) - This toggles on/off levels calculated from the lowest point visible on the chart’s current view.
  • Support: Down (from pivot high) - This toggles on/off levels calculated from the highest point visible on the chart’s current view.
  • 360 - Toggles on/off the levels of full rotations (360 degrees) from price
  • 180 - Toggles on/off the levels of half rotations (180 degrees) from price
  • 90 - Toggles on/off the levels of quarter rotations (90 degrees) from price
  • 45 - Toggles on/off the levels of eighth rotations (45 degrees) from price
  • Full Rotations Visible - The number of rotations to be displayed on the chart

How to use this indicator:
  1. Adjust chart window to change the highs and lows.
  2. Select the degrees, direction, and number of rotations in the indicator settings.
  3. The colored values beside the indicator represent the values (high and low) used in generating the Gann levels. Should the cursor be on the chart, ensure it is to the right of the high and low pivots, as this is dynamic in TradingView depending upon cursor location. Note: This is only for the user to know which value(s) are used; cursor position does not impact actual calculations and levels displayed.
  4. The levels will be drawn to the right of the most recent price, labeled with the degrees and direction as well as the price value at the level.

About the calculations:
These calculations are derived from the Natural Square Calculator of Gann Theory, also known as the Square of Nines.
  • Details:
    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.
  • Ex: Low of 100. Calculate Gann resistance level for 360 degrees. (√(100)+2)² = 144.
  • Ex: High of 100. Calculate Gann support level for 180 degrees. (√(100)-1)² = 81.
版本注释:
Added Feature - Scaling Down Large Numbers

Why: Requested by indicator users.
What: Allows the indicator to scale down numbers larger than 1000 (normalize to three digits) for Gann calculations and then rescale (restore) the output to the original magnitude before charting levels.
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.
Toggle: By default, this operation is enabled but can be turned off in the settings.

How: Details on the mathematics behind this feature:
  1. 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)
  2. 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)
  3. Perform regular Gann calculations with these as the high and low inputs (see indicator description above for details).
  4. Scale up the Gann calculation outputs by multiplying by10^magnitude and draw to chart.
    gann * math.pow(10, magnitude)
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?