Implementing Gann Square of 9 for Predictive Analysis in ProBuilder

23 Mar 2024
0 comment
0 attachment

This code snippet demonstrates how to use the Gann Square of 9 method to predict the next price level based on the current value of the RSI (Relative Strength Index) over 14 periods. The Gann Square of 9 is a trading tool that is used to determine key levels of support and resistance and predict future prices. This example is tailored for users of ProRealTime’s ProBuilder language, specifically for versions 10.3 and 11.

#### Code Snippet:
For ProRealTime v10.3:


defparam drawonlastbaronly=true
//X = starting price
X = rsi[14]
//a = angle
a = 45
//Y = next price
Y = square(sqrt(X) + a/180)
//plot the next price
drawline(barindex, X, barindex+1, Y)
return X as "price/indi value"

For ProRealTime v11:


defparam drawonlastbaronly=true
//X = starting price
X = rsi[14]
//a = angle
a = 45
//Y = next price
Y = square(sqrt(X) + a/180)
//plot the next price
drawsegment(barindex, X, barindex+10, Y) coloured(255,200,0) style(line,3)
drawpoint(barindex, X, 3) coloured(255,0,0)
drawpoint(barindex+10, Y, 3) coloured(255,0,0)
return X as "price/indi value"

#### Explanation and Steps:

  • Parameter Setup: The defparam drawonlastbaronly=true directive ensures that drawing commands only affect the last bar on the chart, keeping the display clean and focused on recent data.
  • Calculating the Starting Price: X = rsi[14] assigns the value of the 14-period RSI to X, which serves as the starting point for our calculation.
  • Setting the Angle: The angle a is set to 45 degrees, a common angle used in Gann theory to determine significant price movements.
  • Calculating the Next Price: Y = square(sqrt(X) + a/180) calculates the next price level based on the Gann Square of 9 method. This involves taking the square root of X, adjusting it by the angle converted to radians (a/180), and then squaring the result to get Y.
  • Drawing the Prediction: In version 10.3, drawline is used to connect the current price/index to the next predicted price/index. In version 11, drawsegment enhances visualization by allowing customization of the line’s color and style, and drawpoint marks the current and predicted prices with colored points for better visibility.
  • Output: The function returns the current RSI value as “price/indi value”, which can be used for further analysis or display.

This example provides a practical application of Gann’s theory in financial markets analysis using ProBuilder, illustrating how to project future price levels from a given RSI value.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/dessiner-gan-eventail/#post-143088

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...