Fibonacci retrace from RTH close to open by Mobius

MakePlays

New member
Code:
# Fibonacci retrace from RTH close to open
# Mobius
# Request 07.13.2021

input Fib_Coeff1 = .382;
input Fib_Coeff2 = .500;
input Fib_Coeff3 = .618;

def o = open;
def c = close;
def x = barNumber();
def t1 = getTime() crosses above RegularTradingEnd(getYYYYMMDD());
def t2 = getTime() crosses above RegularTradingStart(getYYYYMMDD());
def c1 = if t1
         then close(period = "DAY")[1]
         else c1[1];
def c2 = if t2
        then o
        else c2[1];
def x1 = if t1 then x else x1[1];
def x2 = if t2 then x else x2[1];
def x3 = if x1 != x1[1] then x1[1] else x3[1];
def x4 = if x2 != x2[1] then x2[1] else x4[1];
plot line = if x == highestAll(min(x1, x3))
            then close
            else if x == highestAll(max(x2, x4))
            then open
            else double.nan;
     line.SetDefaultColor(color.gray);
     line.EnableApproximation();
addVerticalLine(t1);
addVerticalLine(t2);
def r = c1 - c2;
plot fib_0 = if x >= highestAll(x2)then highestAll(c1) else double.nan;
     fib_0.SetDefaultColor(Color.gray);
addChartBubble(isNaN(close[2]) and !isNaN(close[3]), fib_0, "Fib 0", color.gray, yes);
plot fib_1 = if x >= highestAll(x2) then highestAll(c1 - (r * Fib_Coeff1)) else double.nan;
     fib_1.SetDefaultColor(Color.gray);
addChartBubble(isNaN(close[2]) and !isNaN(close[3]), fib_1, "Fib " + fib_Coeff1, color.gray, yes);
plot fib_2 = if x >= highestAll(x2) then  highestAll(c1 - (r * Fib_Coeff2)) else double.nan;
     fib_2.SetDefaultColor(Color.gray);
addChartBubble(isNaN(close[2]) and !isNaN(close[3]), fib_2, "Fib " + fib_Coeff2, color.gray, yes);
plot fib_3 = if x >= highestAll(x2) then  highestAlL(c1 - (r * Fib_Coeff3)) else double.nan;
     fib_3.SetDefaultColor(Color.gray);
addChartBubble(isNaN(close[2]) and !isNaN(close[3]), fib_3, "Fib " + fib_Coeff3, color.gray, yes);
plot fib_4 =  if x >= highestAll(x2) then highestAll(c2) else double.nan;
     fib_4.SetDefaultColor(Color.gray);
addChartBubble(isNaN(close[2]) and !isNaN(close[3]), fib_4, "Fib 100", color.gray, yes);
# End Code Fib Retrace
 
Last edited by a moderator:
Top