# GannSO9_LOV
# ===============================================================
# Dislaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk.
# ===============================================================
# Gann Square Of Numbers
# Using the Law Of Vibrations (LOV)
# The LOV number is taken from the stock's life path number
# Reference Material
# Physics Of Musical Notes: http://pages.mtu.edu/~suits/Physicsofmusic.html
# Frequencies for equal-tempered scale, A4 = 440 Hz: http://pages.mtu.edu/~suits/notefreqs.html
# Pythagorean Scale: http://pages.mtu.edu/~suits/pythagorean.html
# Frequencies for equal-tempered scale, A4 = 440 Hz
# Questions/Comments to: [email protected]
# Pythagorean Scale: http://www.phys.uconn.edu/~gibson/Notes/Section3_4/Sec3_4.htm
# Life Path Number: https://www.tokenrock.com/numerology/life_path/
# First Trade Dates of Stocks: http://www.magiastrology.com/firsttradedate/mostrecent_ipo.php
# Inception Dates of ETFs: http://www.proshares.com/funds/sds.html
declare upper;
input Square = {"Square Of 3", "Square Of 4", "Square Of 5", "Square Of 6", "Square Of 7", default "Square Of 8", "Square Of 9", "Square Of 10", "Square Of 11", "Square Of 12"};
input Multiplier = {"0.001", "0.01", "0.10", default "1", "10", "100", "1000", "10000"};
input DegreeIncrements = {"11.25", "22.50", default "45.00", "90.00", "180.00"};
input numMonths1 = 5;
input VScale = 0.5;
input HScale = 5.0;
input GridSize = 50;
input Show1 = yes;
input lineWeight = 2;
def numdays = 21;
def numBars1 = numdays * numMonths1;
def barNum = if IsNaN( close ) then Double.NaN else BarNumber();
def lastBar = HighestAll( barNum );
def startBar1 = if lastBar <= numBars1 then 1 else lastBar - numBars1;
def bar = BarNumber();
def hData1 = If( barNum < startBar1, Double.NaN, high );
def lData1 = If( barNum < startBar1, Double.NaN, low );
def a_price = HighestAll(high);
def b_price = LowestAll(low);
def barnumber = BarNumber();
def c_price = if high == a_price then barnumber else Double.NaN;
def d_price = if low == b_price then barnumber else Double.NaN;
rec highnumber = CompoundValue(1, if IsNaN(c_price) then highnumber[1] else c_price, c_price);
def highnumberall = HighestAll(highnumber);
rec lownumber = CompoundValue(1, if IsNaN(d_price) then lownumber[1] else d_price, d_price);
def lownumberall = LowestAll(lownumber);
def months1 = Round( ( lastBar - startBar1 + 1 ) / 21, 0 );
plot HighestHigh1 = If( Show1, HighestAll( hData1 ), Double.NaN );
plot LowestLow1 = If( Show1, LowestAll( lData1 ), Double.NaN );
# ===============================================================
# Chart Bubbles
# ===============================================================
def BeginBarH = if barNum >= startBar1 and HighestAll(HighestHigh1) == high
then BarNumber() else BeginBarH[1];
def BeginBarL = if barNum >= startBar1 and HighestAll(LowestLow1) == low
then BarNumber() else BeginBarL[1];
def BeginBar = HighestAll(Min(BeginBarH, BeginBarL));
# ===============================================================
# Plotting Section
# ===============================================================
#===================[ Define Plot Appearences ]=====================
DefineGlobalColor( "H1", Color.VIOLET);
DefineGlobalColor( "L1", Color.PINK);
HighestHigh1.SetPaintingStrategy( PaintingStrategy.Dashes );
HighestHigh1.SetLineWeight( 1 );
HighestHigh1.AssignValueColor( GlobalColor( "H1" ) );
HighestHigh1.HideBubble();
LowestLow1.SetPaintingStrategy( PaintingStrategy.Dashes );
LowestLow1.SetLineWeight( 1 );
LowestLow1.AssignValueColor( GlobalColor( "L1" ) );
LowestLow1.HideBubble();
AddChartBubble( Show1 and barNum == BeginBar, HighestHigh1, Concat( "Highest High in ", Concat( months1, Concat (" Months is ", HighestHigh1)) ), GlobalColor( "H1" ), yes );
AddChartBubble( Show1 and barNum == BeginBar, LowestLow1, Concat( "Lowest Low in ", Concat( months1, Concat (" Months is ", LowestLow1)) ), GlobalColor( "L1" ), no );
def begindate = if BarNumber() == BeginBar then GetYYYYMMDD() else begindate[1];
def beginclose = if BarNumber() == BeginBar then close else beginclose[1];
def enddate = if BarNumber() == BeginBar + GridSize then GetYYYYMMDD() else enddate[1];
def BeginPrice = HighestAll(Min(HighestHigh1, LowestLow1));
# =============================
# SquareOf
# Gann Musical Value from each musical note
# =============================
def GMV;
switch (Square) {
case "Square Of 3":
GMV = 1.25992;
case "Square Of 4":
GMV = 1.41421;
case "Square Of 5":
GMV = 1.49831;
case "Square Of 6":
GMV = 1.68179;
case "Square Of 7":
GMV = 1.88775;
case "Square Of 8":
GMV = 2.00000;
case "Square Of 9":
GMV = 2.24492;
case "Square Of 10":
GMV = 2.51984;
case "Square Of 11":
GMV = 2.82843;
case "Square Of 12":
GMV = 2.99661;
}
# ===============================================================
def Multiplier_N;
switch (Multiplier) {
case "0.001":
Multiplier_N = 0.001;
case "0.01":
Multiplier_N = 0.01;
case "0.10":
Multiplier_N = 0.10;
case "1":
Multiplier_N = 1.00;
case "10":
Multiplier_N = 10;
case "100":
Multiplier_N = 1000;
case "1000":
Multiplier_N = 1000;
case "10000":
Multiplier_N = 10000;
}
# ===============================================================
def Degrees_N;
switch (DegreeIncrements) {
case "11.25":
Degrees_N = 11.25;
case "22.50":
Degrees_N = 22.50;
case "45.00":
Degrees_N = 45.00;
case "90.00":
Degrees_N = 90.00;
case "180.00":
Degrees_N = 180.00;
}
# ===============================================================
# Gann Square Section
# ===============================================================
def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;
# =============================
# Plot Gann Square Root Horizontal Lines
# =============================
def BaseValue = if bar >= BeginBar and BeginBarH == BeginBar
then HighestHigh1
else if bar >= BeginBar and BeginBarL == BeginBar
then LowestLow1
else double.nan;
def startbar = if GetYYYYMMDD() == begindate then BarNumber() else startbar[1];
plot GLH0 = if barnumber between startbar and startbar + numBars1 then BaseValue else Double.NaN;
# def Focus = Sqrt(beginclose);
def Cycle = 360 / Degrees_N;
def Focus = Sqrt(BaseValue);
def Factor = GMV / Cycle;
def GannValue = Focus + (1 * GMV) * Multiplier_N;
def GannLevel = Sqr(Focus + (1 * Cycle))/Multiplier_N;
plot GLH1 = if upward
then Sqr(Focus + (1 * Factor)) * Multiplier_N
else Sqr(Focus - (1 * Factor)) * Multiplier_N;
plot GLH2 = if upward
then Sqr(Focus + (2 * Factor)) * Multiplier_N
else Sqr(Focus - (2 * Factor)) * Multiplier_N;
plot GLH3 = if upward
then Sqr(Focus + (3 * Factor)) * Multiplier_N
else Sqr(Focus - (3 * Factor)) * Multiplier_N;
plot GLH4 = if upward
then Sqr(Focus + (4 * Factor)) * Multiplier_N
else Sqr(Focus - (4 * Factor)) * Multiplier_N;
plot GLH5 = if upward
then Sqr(Focus + (5 * Factor)) * Multiplier_N
else Sqr(Focus - (5 * Factor)) * Multiplier_N;
plot GLH6 = if upward
then Sqr(Focus + (6 * Factor)) * Multiplier_N
else Sqr(Focus - (6 * Factor)) * Multiplier_N;
plot GLH7 = if upward
then Sqr(Focus + (7 * Factor)) * Multiplier_N
else Sqr(Focus - (7 * Factor)) * Multiplier_N;
plot GLH8 = if upward
then Sqr(Focus + (8 * Factor)) * Multiplier_N
else Sqr(Focus - (8 * Factor)) * Multiplier_N;
plot GLH9 = if upward
then Sqr(Focus + (9 * Factor)) * Multiplier_N
else Sqr(Focus - (9 * Factor)) * Multiplier_N;
plot GLH10 = if upward
then Sqr(Focus + (10 * Factor)) * Multiplier_N
else Sqr(Focus - (10 * Factor)) * Multiplier_N;
plot GLH11 = if upward
then Sqr(Focus + (11 * Factor)) * Multiplier_N
else Sqr(Focus - (11 * Factor)) * Multiplier_N;
plot GLH12 = if upward
then Sqr(Focus + (12 * Factor)) * Multiplier_N
else Sqr(Focus - (12 * Factor)) * Multiplier_N;
plot GLH13 = if upward
then Sqr(Focus + (13 * Factor)) * Multiplier_N
else Sqr(Focus - (13 * Factor)) * Multiplier_N;
plot GLH14 = if upward
then Sqr(Focus + (14 * Factor)) * Multiplier_N
else Sqr(Focus - (14 * Factor)) * Multiplier_N;
plot GLH15 = if upward
then Sqr(Focus + (15 * Factor)) * Multiplier_N
else Sqr(Focus - (15 * Factor)) * Multiplier_N;
plot GLH16 = if upward
then Sqr(Focus + (16 * Factor)) * Multiplier_N
else Sqr(Focus - (16 * Factor)) * Multiplier_N;
plot GLH17 = if upward
then Sqr(Focus + (17 * Factor)) * Multiplier_N
else Sqr(Focus - (17 * Factor)) * Multiplier_N;
plot GLH18 = if upward
then Sqr(Focus + (18 * Factor)) * Multiplier_N
else Sqr(Focus - (18 * Factor)) * Multiplier_N;
plot GLH19 = if upward
then Sqr(Focus + (19 * Factor)) * Multiplier_N
else Sqr(Focus - (19 * Factor)) * Multiplier_N;
plot GLH20 = if upward
then Sqr(Focus + (20 * Factor)) * Multiplier_N
else Sqr(Focus - (20 * Factor)) * Multiplier_N;
# =============================
# Format Gann Square Root Lines
# =============================
GLH0.SetDefaultColor(Color.BLUE);
GLH0.SetLineWeight(lineWeight);
GLH0.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH0, Concat(0 * Degrees_N, " *"), Color.White, yes );
GLH1.SetDefaultColor(Color.BLUE);
GLH1.SetLineWeight(lineWeight);
GLH1.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH1, Concat(1 * Degrees_N, " *"), Color.White, yes );
GLH2.SetDefaultColor(Color.BLUE);
GLH2.SetLineWeight(lineWeight);
GLH2.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH2, Concat(2 * Degrees_N, " *"), Color.White, yes );
GLH3.SetDefaultColor(Color.BLUE);
GLH3.SetLineWeight(lineWeight);
GLH3.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH3, Concat(3 * Degrees_N, " *"), Color.White, yes );
GLH4.SetDefaultColor(Color.BLUE);
GLH4.SetLineWeight(lineWeight);
GLH4.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH4, Concat(4 * Degrees_N, " *"), Color.White, yes );
GLH5.SetDefaultColor(Color.BLUE);
GLH5.SetLineWeight(lineWeight);
GLH5.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH5, Concat(5 * Degrees_N, " *"), Color.White, yes );
GLH6.SetDefaultColor(Color.BLUE);
GLH6.SetLineWeight(lineWeight);
GLH6.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH6, Concat(6 * Degrees_N, " *"), Color.White, yes );
GLH7.SetDefaultColor(Color.Blue);
GLH7.SetLineWeight(lineWeight);
GLH7.SetPaintingStrategy(PaintingStrategy.line);
AddChartBubble( barNum == BeginBar, GLH7, Concat(7 * Degrees_N, " *"), Color.White, yes );
GLH8.SetDefaultColor(Color.BLUE);
GLH8.SetLineWeight(lineWeight);
GLH8.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH8, Concat(8 * Degrees_N, " *"), Color.White, yes );
GLH9.SetDefaultColor(Color.BLUE);
GLH9.SetLineWeight(lineWeight);
GLH9.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH9, Concat(9 * Degrees_N, " *"), Color.White, yes );
GLH10.SetDefaultColor(Color.BLUE);
GLH10.SetLineWeight(lineWeight);
GLH10.SetPaintingStrategy(PaintingStrategy.LINE);
AddChartBubble( barNum == BeginBar, GLH10, Concat(10 * Degrees_N, " *"), Color.White, yes );
GLH11.SetDefaultColor(Color.BLUE);
GLH11.SetLineWeight(lineWeight);
GLH11.SetPaintingStrategy(PaintingStrategy.LINE);
GLH12.SetDefaultColor(Color.BLUE);
GLH12.SetLineWeight(lineWeight);
GLH12.SetPaintingStrategy(PaintingStrategy.LINE);
GLH13.SetDefaultColor(Color.BLUE);
GLH13.SetLineWeight(lineWeight);
GLH13.SetPaintingStrategy(PaintingStrategy.LINE);
GLH14.SetDefaultColor(Color.BLUE);
GLH14.SetLineWeight(lineWeight);
GLH14.SetPaintingStrategy(PaintingStrategy.LINE);
GLH15.SetDefaultColor(Color.BLUE);
GLH15.SetLineWeight(lineWeight);
GLH15.SetPaintingStrategy(PaintingStrategy.LINE);
GLH16.SetDefaultColor(Color.BLUE);
GLH16.SetLineWeight(lineWeight);
GLH16.SetPaintingStrategy(PaintingStrategy.LINE);
GLH17.SetDefaultColor(Color.BLUE);
GLH17.SetLineWeight(lineWeight);
GLH17.SetPaintingStrategy(PaintingStrategy.LINE);
GLH18.SetDefaultColor(Color.BLUE);
GLH18.SetLineWeight(lineWeight);
GLH18.SetPaintingStrategy(PaintingStrategy.LINE);
GLH19.SetDefaultColor(Color.BLUE);
GLH19.SetLineWeight(lineWeight);
GLH19.SetPaintingStrategy(PaintingStrategy.LINE);
GLH20.SetDefaultColor(Color.BLUE);
GLH20.SetLineWeight(lineWeight);
GLH20.SetPaintingStrategy(PaintingStrategy.LINE);
# AddVerticalLine(boolean visible, Any text, CustomColor color, int stroke);
# ===============================================================
# Vertical Lines
# ===============================================================
def VInc = GannValue;
def GLV0 = BeginBar;
def GLV1 = GLV0 + (1 * VInc);
def GLV2 = GLV0 + (2 * VInc);
def GLV3 = GLV0 + (3 * VInc);
def GLV4 = GLV0 + (4 * VInc);
def GLV5 = GLV0 + (5 * VInc);
def GLV6 = GLV0 + (6 * VInc);
def GLV8 = GLV0 + (7 * VInc);
def GLV9 = GLV0 + (8 * VInc);
def GLV10 = GLV0 + (9 * VInc);
def GLV11 = GLV0 + (10 * VInc);
AddVerticalLine(BarNumber() == Floor(GLV0), "", Color.GREEN, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV1), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV2), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV3), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV4), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV5), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV6), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV8), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV9), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV10), "", Color.RED, Curve.FIRM);
AddVerticalLine(BarNumber() == Floor(GLV11), "", Color.RED, Curve.FIRM);
AddVerticalLine( BarNumber() == Floor(BeginBar + GridSize), GetYYYYMMDD() + " ", Color.GRAY, Curve.FIRM);
# ===============================================================
#AddLabel (yes, Square, Color.Light_Gray);
#AddLabel (yes, "GMV: " + GMV, Color.LIGHT_GRAY);
#AddLabel (yes, "Multiplier: " + Multiplier_N, Color.LIGHT_GRAY);
#AddLabel (yes, "GridSize: " + GridSize, Color.LIGHT_GRAY);
#AddLabel (yes, "Horizontal Scale: " + HScale, Color.LIGHT_GRAY);
#AddLabel (yes, "Vertical Scale: " + VScale, Color.LIGHT_GRAY);
#AddLabel (yes, "Degree Increments: " + Degrees_N, Color.LIGHT_GRAY);
#
#AddLabel (yes, "Cycle: " + Cycle, Color.LIGHT_GRAY);
#AddLabel (yes, "Focus: " + Focus, Color.LIGHT_GRAY);
#AddLabel (yes, "Factor: " + Factor, Color.LIGHT_GRAY);
#AddLabel (yes, "GannLevel: " + GannLevel, Color.LIGHT_GRAY);
#AddLabel (yes, "GannValue: " + GannValue, Color.LIGHT_GRAY);
#AddLabel (yes, "GLH1: " + GLH1, Color.LIGHT_GRAY);