Gann Nine Amibroker Code
Gann Nine Amibroker Code
***********************************************************************************
*******
Name : Square of Nine - Roadmap Charts (Amibroker implementation)
Coded by : Lal
Date : 27th March 2008
Note : Grateful thanks to Peter Amaral of Tradingfives.com
To gain an understanding of how these roadmap channels
work, read the article here:
http://www.tradingfives.com/square-of-nine-in-excel.htm
All the lines plotted by this script can extend beyond the
last bar. So
make sure
you have enough blank bars in the right margin (set by
Preferences).
***********************************************************************************
****************/
_SECTION_BEGIN("So9_Params");
Base_Factor = ParamList("Factor",
"0.015625|0.03125|0.0625|0.1250|0.1875|0.2500|0.3125|0.3750|0.4375|0.5|0.5625|
0.6250|0.6875|0.8125|0.8750|0.9375|1.0|1.250|1.5|1.75|2.0|2.5|3.0|4.0",
16);
Multiplier = ParamList("Multiplier", "0.001|0.01|0.10|1|10|100|
1000|10000",
3);
Auto_Price = ParamToggle("Auto-select Price field?", "No|Yes", 1);
Price_Field = ParamField("Use ");
Max_Hor_Lines = Param("Max Hor. Lines", 10, 2, 100, 1);
Plot_Half_Lines = ParamToggle("Hor. HalfLines?", "No|Yes");
Extend_Bars = Param("Extend Plot by", 20, 0, 50, 1);
Channel_Type = ParamList("Channel Type", "Bullish|Bearish|None", 0);
Max_Chanl_Lines = Param("Max Channel Lines", 3, 1, 20, 1);
Show_Degrees = ParamToggle("Show Degrees?", "No|Yes", 1);
_SECTION_END();
_SECTION_BEGIN("Line Colours");
Bull_Line_Color = ParamColor("Bullish Horizontals", colorDarkGreen);
Bull_Half_Color = ParamColor("Bullish Horizontal Halfs", colorRed);
Bull_Vert_Color = ParamColor("Bullish Verticals", colorGrey50);
Bull_Chanl_Color = ParamColor("Bullish Channels", colorDarkGreen);
EnableTextOutput(False);
Vertical = 0;
Start_Bar = SelectedValue(BarIndex());
Start_Y = SelectedValue(Bull_Hor);
End_Bar = BarCount - 1;
End_Y = Start_Y;
Hor_Plot = LineArray(Start_Bar - Extend_Bars, Start_Y, End_Bar,
End_Y, 1);
if(Show_Degrees)
{
PlotText("" + NumToStr(Degrees, 4, 1) + "", Start_bar+2, Start_Y
+ 1 ,
colorBlack);
}
if(i == 1)
{
// Plot the 1st Horizontal. This is a one-time execution.
Plot(LineArray(Start_Bar - Extend_Bars,
SelectedValue(Price_Field), End_Bar,
SelectedValue(Price_Field), 0), "", Bull_Line_Color, styleLine|styleNoRescale,
Null, Null, Extend_Bars);
}
// Work out how many bars to shift the vertical to the right from current
Shift = Next_Vertical[0] - SelectedValue(BarIndex());
Line1 = BarIndex() == SelectedValue(BarIndex()); // are we at current
bar?
Plot(Line1,"", colorRed, styleHistogram| styleOwnScale, Null, Null, Shift) ;
// Plot vertical with a forward shift
Start_Bar = SelectedValue(BarIndex());
Start_Y = SelectedValue(Bear_Hor);
End_Bar = BarCount - 1;
End_Y = Start_Y;
Hor_Plot = LineArray(Start_Bar - Extend_Bars, Start_Y, End_Bar,
End_Y, 1);
if(Show_Degrees)
{
PlotText("" + NumToStr(Degrees, 4, 1) + "", Start_bar+2, Start_Y
+ 1 ,
colorBlack);
}
if(i == 1)
{
// Plot the 1st Horizontal. This is a one-time execution.
Plot(LineArray(Start_Bar - Extend_Bars,
SelectedValue(Price_Field), End_Bar,
SelectedValue(Price_Field), 0), "", Bear_Line_Color,
styleLine|styleThick|styleNoRescale, Null, Null, Extend_Bars);
}
// Work out how many bars to shift the vertical to the right from current
Shift = Next_Vertical[0] - SelectedValue(BarIndex());
Line1 = BarIndex() == SelectedValue(BarIndex()); // are we at current
bar?
Plot(Line1,"", colorDarkGreen, styleHistogram| styleOwnScale|styleNoLabel,
Null, Null, Shift) ; // Plot vertical with a forward shift