#calculates gann square of 9 based on either todays open or yesterdays close.
input aggregationPeriod = AggregationPeriod.DAY;
def yesterday= close(period = aggregationPeriod)[1];
#def today = open(period = aggregationPeriod);
def sh= yesterday;
def data00 = Sqrt(sh) - (0 / 180);
def data0 = Power(data00, 2);
plot line00 = data0;
def data45 = Sqrt(sh) - (45 / 180);
def data1 = Power(data45, 2);
plot line45 = data1;
def up1 = sh- line45;
plot up11 = up1+ sh;
line45.SetDefaultColor(Color.GREEN);
up11.SetDefaultColor(Color.red);
def data90 = Sqrt(sh) - (90 / 180);
def data2 = Power(data90, 2);
plot line90 = data2;
def up2 = sh- line90;
plot up22= sh +up2;
up22.SetDefaultColor(Color.red);
line90.SetDefaultColor(Color.GREEN);
def data135 = Sqrt(sh) - (135 / 180);
def data3 = Power(data135, 2);
plot line135 = data3;
def up3 = sh- line135;
plot up33 = sh+ up3;
up33.SetDefaultColor(Color.red);
line135.SetDefaultColor(Color.GREEN);