Fib Calculations

Hello, I am trying to script the weekly higher high and higher low using fib calculations using 127.2%, 161.8%, 200%, and 261.8%.

I have this script of 52 weeks highs and lows; can you modify this script with these fibs, please?

//Get 52 week high and low;
H1 = LAST(HIGHESTHIGH(RANGE=Look Back Period, BACKTYPE=Weeks, BARS=52, INCBAR=True));
L1 = LAST(LOWESTLOW(RANGE=Look Back Period, BACKTYPE=Weeks, BARS=52, INCBAR=True));
//Calc range;
R1 = (H1-L1);

//Calc Fib levels;
Plot1 = H1;
Plot2 = L1 + (R1 * 0.618);
Plot3 = L1 + (R1 * 0.5);
Plot4 = L1 + (R1 * 0.382);
Plot5 = L1;

//Set line styles;
Plot1.Colour = Green;
Plot1.Linestyle = Dash;
Plot1.LineWidth = 2;

Plot2.Colour = Blue;
Plot2.Linestyle = Dash;

Plot3.Colour = Red;
Plot3.Linestyle = Dash;
Plot3.LineWidth = 2;

Plot4.Colour = Blue;
Plot4.Linestyle = Dash;

Plot5.Colour = Green;
Plot5.Linestyle = Dash;
Plot5.LineWidth = 2;

Thanks,
Mo

Fib Extensions.

Here is a screen shot if that helps,

Hey Mo try this, which will also draw the weekly levels on a daily chart using the Show Plot tool:

//Get week high and low;
H1 = LAST(HIGH(Week(PERIODAMOUNT=1)));
L1 = LAST(LOW(Week(PERIODAMOUNT=1)));
//Calc range;
R1 = (H1-L1);

//Calc Fib levels;
Plot1 = H1;
Plot2 = L1 + (R1 * 2.618);
Plot3 = L1 + (R1 * 2);
Plot4 = L1 + (R1 * 1.618);
Plot5 = L1 +(R1 * 1.272);
Plot6 = L1 +(R1 * -0.272);
Plot7 = L1 +(R1 * -0.618);
Plot8 = L1 +(R1 * -1);
Plot9 = L1 +(R1 * -1.618);
Plot10 = L1;

//Set line styles;
Plot1.Colour = Red;
Plot1.Linestyle = Dash;
Plot1.LineWidth = 2;

Plot10.Colour = Red;
Plot10.Linestyle = Dash;
Plot10.LineWidth = 2;

2 Likes

Thank you. I appreciate it. If I have to change it to a daily Fib extension, I can just change the week to daily and leave the script as is?

No worries. Set the timeframe in H1 and L1 to Default and it will automatically use the timeframe of the chart it’s applied to, so switching to daily chart will draw the levels based on the last daily bar ie LAST(HIGH()) and LAST(LOW()).

1 Like

Perfect. I like to trade on 1 hour time using these fib extensions.

1 Like