Need help creating a Custom Fib indicator

Juxtapose

New member
Hey Guys,

I have a custom fib that I want to have scripted. It's gears towards certain fib levels that I wish to set. I would like to have this fib automatically generate at trading day with the high and low of the opening candle. Is there anyone out here that can help me out?
 
Last edited:
All, I attempted to create my custom script for the fib but am not getting it right. Anyone can lend some idea? I took the Fib script and added the custom numbers

Code:
##Begin

#hint: <b>Fibonacci Retracements</b>\nFibonacci retracements use horizontal lines to indicate areas of support or resistance at the key Fibonacci levels before it continues in the original direction. These levels are created by drawing a trendline between two extreme points and then dividing the vertical distance by the key Fibonacci ratios of: 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%.


#hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b>
#hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>
#hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b>

#hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.\n <b>(Default is -2.618%)</b>
#hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.\n <b>(Default is -1.618%)</b>
#hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.\n <b>(Default is -0.618%)</b>
#hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.\n <b>(Default is -0.272%)</b>
#hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.\n <b>(Default is 0%)</b>
#hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.\n <b>(Default is 0.236%)</b>
#hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.\n <b>(Default is 0.382%)</b>
#hint Coefficient_7: Retracement Line 7: Retracement from the highest high to the lowest low.\n <b>(Default is 0.5%)</b>
#hint Coefficient_8: Retracement Line 8: Retracement from the highest high to the lowest low.\n <b>(Default is 0.618%)</b>
#hint Coefficient_9: Retracement Line 9: Retracement from the highest high to the lowest low.\n <b>(Default is 0.786%)</b>
#hint Coefficient_10: Retracement Line 10: Retracement from the highest high to the lowest low.\n <b>(Default is 1%)</b>
#hint Coefficient_11: Retracement Line 11: Retracement from the highest high to the lowest low.\n <b>(Default is 1.272%)</b>
#hint Coefficient_12: Retracement Line 12: Retracement from the highest high to the lowest low.\n <b>(Default is 1.618%)</b>
#hint Coefficient_13: Retracement Line 13: Retracement from the highest high to the lowest low.\n <b>(Default is 2.618%)</b>
#hint Coefficient_14: Retracement Line 14: Retracement from the highest high to the lowest low.\n <b>(Default is 4.236%)</b>


#wizard input: Price
#wizard text: Inputs: Price:
#wizard input: onExpansion
#wizard text: onExpansion:
#wizard input: Extend_to_left
#wizard text: Extend_to_left:
#wizard input: Coefficient0
#wizard text: Coefficient0:
#wizard input: Coefficient_1
#wizard text: Coefficient_1:
#wizard input: Coefficient_2
#wizard text: Coefficient_2:
#wizard input: Coefficient_3
#wizard text: Coefficient_3:
#wizard input: Coefficient_4
#wizard text: Coefficient_4:
#wizard input: Coefficient_5
#wizard text: Coefficient_5:
#wizard input: Coefficient_6
#wizard text: Coefficient_6:
#wizard input: Coefficient_7
#wizard text: Coefficient_7:
#wizard input: Coefficient_8
#wizard text: Coefficient_8:
#wizard input: Coefficient_9
#wizard text: Coefficient_9:
#wizard input: Coefficient_10
#wizard text: Coefficient_10:
#wizard input: Coefficient_11
#wizard text: Coefficient_11:
#wizard input: Coefficient_12
#wizard text: Coefficient_12:
#wizard input: Coefficient_13
#wizard text: Coefficient_13:
#wizard input: Coefficient_14
#wizard text: Coefficient_14:


input price = close;
input high = high;
input low = low;
input onExpansion = Yes;
input Extend_to_left = no;
input Coefficient0 = -2.618;
input coefficient_1 = -1.618;
input Coefficient_2 = -0.618;
input Coefficient_3 = -0.272;
input Coefficient_4 = 0;
Input Coefficient_5 = 0.236;
input Coefficient_6 = 0.382;
input Coefficient_7 = 0.5;
input Coefficient_8 = 0.618;
input Coefficient_9 = 0.786;
input Coefficient_10 = 1;
input Coefficient_11 = 1.272;
input Coefficient_12 = 1.618;
input Coefficient_13 = 2.618;
input Coefficient_14 = 4.236;


def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;

def x = AbsValue(lownumberall - highnumberall );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);
def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan);

def line = b + (slope * (barnumber - lownumber));
def linelow = a + (slopelow * (barnumber - highnumber));

def currentlinelow = if barnumber <= lownumberall then linelow else double.nan;
def currentline = if barnumber <= highnumberall then line else double.nan;

Plot FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;
FibFan.SetStyle(Curve.SHORT_DASH);
FibFan.AssignValueColor(color.red);
fibfan.hidebubble();

def range =  a - b;

Plot Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;
Retracement0.assignvaluecolor(color.red);
retracement0.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement0, concat( "$", round(retracement0, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, yes);


Plot Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;
Retracement1.assignvaluecolor(color.red);
retracement1.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement1, concat( "$", round(retracement1, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, yes);

Plot Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;
Retracement2.assignvaluecolor(color.red);
retracement2.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement2, concat( "$", round(retracement2, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);


Plot Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;
Retracement3.assignvaluecolor(color.red);
retracement3.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement3, concat( "$", round(retracement3, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);


Plot Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;
Retracement4.assignvaluecolor(color.red);
retracement4.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement4, concat( "$", round(retracement4, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, yes);

Plot Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;
Retracement5.assignvaluecolor(color.red);
retracement5.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement5, concat( "$", round(retracement5, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, yes);


Plot Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;
Retracement6.assignvaluecolor(color.red);
retracement6.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement6, concat( "$", round(retracement6, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, yes);


Plot Retracement7 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_7)) else double.nan;
Retracement7.assignvaluecolor(color.red);
retracement7.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement7, concat( "$", round(retracement7, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement7, concat( (coefficient_7 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement7, concat( (coefficient_7 * 100), "%"), color.red, yes);


Plot Retracement8 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_8)) else double.nan;
Retracement8.assignvaluecolor(color.red);
retracement8.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement8, concat( "$", round(retracement8, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement8, concat( (coefficient_8 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement8, concat( (coefficient_8 * 100), "%"), color.red, yes);


Plot Retracement9 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_9)) else double.nan;
Retracement9.assignvaluecolor(color.red);
retracement9.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement9, concat( "$", round(retracement9, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement9, concat( (coefficient_9 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement9, concat( (coefficient_9 * 100), "%"), color.red, yes);


Plot Retracement10 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_10)) else double.nan;
Retracement10.assignvaluecolor(color.red);
retracement10.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement10, concat( "$", round(retracement10, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement10, concat( (coefficient_10 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement10, concat( (coefficient_10 * 100), "%"), color.red, yes);


Plot Retracement11 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_11)) else double.nan;
Retracement11.assignvaluecolor(color.red);
retracement11.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement11, concat( "$", round(retracement11, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement11, concat( (coefficient_11 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement11, concat( (coefficient_11 * 100), "%"), color.red, yes);


Plot Retracement12 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_12)) else double.nan;
Retracement12.assignvaluecolor(color.red);
retracement12.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement12, concat( "$", round(retracement12, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement12, concat( (coefficient_12 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement12, concat( (coefficient_12 * 100), "%"), color.red, yes);


Plot Retracement13 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_13)) else double.nan;
Retracement13.assignvaluecolor(color.red);
retracement13.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement13, concat( "$", round(retracement13, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement13, concat( (coefficient_13 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement13, concat( (coefficient_13 * 100), "%"), color.red, yes);


Plot Retracement14 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_14)) else double.nan;
Retracement14.assignvaluecolor(color.red);
retracement14.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement14, concat( "$", round(retracement14, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement14, concat( (coefficient_14 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement14, concat( (coefficient_14 * 100), "%"), color.red, yes);


alert((price crosses below Retracement0) , "Price crosses below Retracement Line 0");
alert((price crosses above Retracement0) , "Price crosses above Retracement Line 0");
alert((price crosses below Retracement1) , "Price crosses below Retracement Line 1");
alert((price crosses above Retracement1) , "Price crosses above Retracement Line 1");
alert((price crosses below Retracement2) , "Price crosses below Retracement Line 2");
alert((price crosses above Retracement2) , "Price crosses above Retracement Line 2");
alert((price crosses below Retracement3) , "Price crosses below Retracement Line 3");
alert((price crosses above Retracement3) , "Price crosses above Retracement Line 3");
alert((price crosses below Retracement4) , "Price crosses below Retracement Line 4");
alert((price crosses above Retracement4) , "Price crosses above Retracement Line 4");
alert((price crosses below Retracement5) , "Price crosses below Retracement Line 5");
alert((price crosses above Retracement5) , "Price crosses above Retracement Line 5");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 6");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 6");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 7");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 7");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 8");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 8");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 9");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 9");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 10");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 10");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 11");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 11");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 12");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 12");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 13");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 13");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 14");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 14");
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

upon correcting the Coefficient and other valuable, the value of my lines are reversed.

Code:
##Begin

#hint: <b>Fibonacci Retracements</b>\nFibonacci retracements use horizontal lines to indicate areas of support or resistance at the key Fibonacci levels before it continues in the original direction. These levels are created by drawing a trendline between two extreme points and then dividing the vertical distance by the key Fibonacci ratios.


#hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b>
#hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>
#hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b>


#hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.\n <b>(Default is 4.236%)</b>
#hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.\n <b>(Default is 2.618%)</b>
#hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.\n <b>(Default is 1.618%)</b>
#hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.\n <b>(Default is 1.272%)</b>
#hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.\n <b>(Default is 1%)</b>
#hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.\n <b>(Default is 0.786%)</b>
#hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.\n <b>(Default is 0.618%)</b>
#hint Coefficient_7: Retracement Line 7: Retracement from the highest high to the lowest low.\n <b>(Default is 0.5%)</b>
#hint Coefficient_8: Retracement Line 8: Retracement from the highest high to the lowest low.\n <b>(Default is 0.382%)</b>
#hint Coefficient_9: Retracement Line 9: Retracement from the highest high to the lowest low.\n <b>(Default is 0.236%)</b>
#hint Coefficient_10: Retracement Line 10: Retracement from the highest high to the lowest low.\n <b>(Default is 0%)</b>
#hint Coefficient_11: Retracement Line 11: Retracement from the highest high to the lowest low.\n <b>(Default is -0.272%)</b>
#hint Coefficient_12: Retracement Line 12: Retracement from the highest high to the lowest low.\n <b>(Default is -0.618%)</b>
#hint Coefficient_13: Retracement Line 13: Retracement from the highest high to the lowest low.\n <b>(Default is -1.618%)</b>
#hint Coefficient_14: Retracement Line 14: Retracement from the highest high to the lowest low.\n <b>(Default is -2.618%)</b>


#wizard input: Price
#wizard text: Inputs: Price:
#wizard input: onExpansion
#wizard text: onExpansion:
#wizard input: Extend_to_left
#wizard text: Extend_to_left:
#wizard input: Coefficient0
#wizard text: Coefficient0:
#wizard input: Coefficient_1
#wizard text: Coefficient_1:
#wizard input: Coefficient_2
#wizard text: Coefficient_2:
#wizard input: Coefficient_3
#wizard text: Coefficient_3:
#wizard input: Coefficient_4
#wizard text: Coefficient_4:
#wizard input: Coefficient_5
#wizard text: Coefficient_5:
#wizard input: Coefficient_6
#wizard text: Coefficient_6:
#wizard input: Coefficient_7
#wizard text: Coefficient_7:
#wizard input: Coefficient_8
#wizard text: Coefficient_8:
#wizard input: Coefficient_9
#wizard text: Coefficient_9:
#wizard input: Coefficient_10
#wizard text: Coefficient_10:
#wizard input: Coefficient_11
#wizard text: Coefficient_11:
#wizard input: Coefficient_12
#wizard text: Coefficient_12:
#wizard input: Coefficient_13
#wizard text: Coefficient_13:
#wizard input: Coefficient_14
#wizard text: Coefficient_14:


input price = close;
input high = high;
input low = low;
input onExpansion = Yes;
input Extend_to_left = no;
input Coefficient0 = 4.236;
input coefficient_1 = 2.618;
input Coefficient_2 = 1.618;
input Coefficient_3 = 1.272;
input Coefficient_4 = 1;
Input Coefficient_5 = 0.786;
input Coefficient_6 = 0.618;
input Coefficient_7 = 0.5;
input Coefficient_8 = 0.382;
input Coefficient_9 = 0.236;
input Coefficient_10 = 0;
input Coefficient_11 = -0.272;
input Coefficient_12 = -0.618;
input Coefficient_13 = -1.618;
input Coefficient_14 = -2.618;


def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;

def x = AbsValue(lownumberall - highnumberall );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);
def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan);

def line = b + (slope * (barnumber - lownumber));
def linelow = a + (slopelow * (barnumber - highnumber));

def currentlinelow = if barnumber <= lownumberall then linelow else double.nan;
def currentline = if barnumber <= highnumberall then line else double.nan;

Plot FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;
FibFan.SetStyle(Curve.SHORT_DASH);
FibFan.AssignValueColor(color.red);
fibfan.hidebubble();

def range =  a - b;

Plot Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;
Retracement0.assignvaluecolor(color.red);
retracement0.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement0, concat( "$", round(retracement0, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement0, concat( (coefficient0 * 100), "%"), color.red, yes);


Plot Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;
Retracement1.assignvaluecolor(color.red);
retracement1.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement1, concat( "$", round(retracement1, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement1, concat( (coefficient_1 * 100), "%"), color.red, yes);

Plot Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;
Retracement2.assignvaluecolor(color.red);
retracement2.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement2, concat( "$", round(retracement2, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement2, concat( (coefficient_2 * 100), "%"), color.red, yes);


Plot Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;
Retracement3.assignvaluecolor(color.red);
retracement3.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement3, concat( "$", round(retracement3, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%"), color.red, yes);


Plot Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;
Retracement4.assignvaluecolor(color.red);
retracement4.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement4, concat( "$", round(retracement4, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement4, concat( (coefficient_4 * 100), "%"), color.red, yes);

Plot Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;
Retracement5.assignvaluecolor(color.red);
retracement5.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement5, concat( "$", round(retracement5, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement5, concat( (coefficient_5 * 100), "%"), color.red, yes);


Plot Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;
Retracement6.assignvaluecolor(color.red);
retracement6.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement6, concat( "$", round(retracement6, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement6, concat( (coefficient_6 * 100), "%"), color.red, yes);


Plot Retracement7 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_7))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_7)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_7))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_7)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_7))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_7)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_7))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_7)) else double.nan;
Retracement7.assignvaluecolor(color.red);
retracement7.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement7, concat( "$", round(retracement7, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement7, concat( (coefficient_7 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement7, concat( (coefficient_7 * 100), "%"), color.red, yes);


Plot Retracement8 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_8))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_8)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_8))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_8)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_8))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_8)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_8))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_8)) else double.nan;
Retracement8.assignvaluecolor(color.red);
retracement8.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement8, concat( "$", round(retracement8, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement8, concat( (coefficient_8 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement8, concat( (coefficient_8 * 100), "%"), color.red, yes);


Plot Retracement9 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_9))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_9)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_9))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_9)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_9))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_9)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_9))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_9)) else double.nan;
Retracement9.assignvaluecolor(color.red);
retracement9.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement9, concat( "$", round(retracement9, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement9, concat( (coefficient_9 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement9, concat( (coefficient_9 * 100), "%"), color.red, yes);


Plot Retracement10 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_10))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_10)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_10))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_10)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_10))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_10)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_10))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_10)) else double.nan;
Retracement10.assignvaluecolor(color.red);
retracement10.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement10, concat( "$", round(retracement10, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement10, concat( (coefficient_10 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement10, concat( (coefficient_10 * 100), "%"), color.red, yes);

Plot Retracement11 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_11))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_11)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_11))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_11)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_11))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_11)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_11))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_11)) else double.nan;
Retracement11.assignvaluecolor(color.red);
retracement11.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement11, concat( "$", round(retracement11, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement11, concat( (coefficient_11 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement11, concat( (coefficient_11 * 100), "%"), color.red, yes);

Plot Retracement12 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_12))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_12)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_12))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_12)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_12))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_12)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_12))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_12)) else double.nan;
Retracement12.assignvaluecolor(color.red);
retracement12.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement12, concat( "$", round(retracement12, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement12, concat( (coefficient_12 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement12, concat( (coefficient_12 * 100), "%"), color.red, yes);

Plot Retracement13 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_13))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_13)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_13))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_13)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_13))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_13)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_13))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_13)) else double.nan;
Retracement13.assignvaluecolor(color.red);
retracement13.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement13, concat( "$", round(retracement13, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement13, concat( (coefficient_13 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement13, concat( (coefficient_13 * 100), "%"), color.red, yes);

Plot Retracement14 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_14))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_14)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_14))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_14)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_14))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_14)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_14))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_14)) else double.nan;
Retracement14.assignvaluecolor(color.red);
retracement14.hidebubble();
AddChartBubble((barnumber == istodaybarnumber), retracement14, concat( "$", round(retracement14, 2)), color.red, yes);
AddChartBubble((downward and barnumber == highnumberall), retracement14, concat( (coefficient_14 * 100), "%"), color.red, yes);
AddChartBubble((upward and barnumber == lownumberall), retracement14, concat( (coefficient_14 * 100), "%"), color.red, yes);


alert((price crosses below Retracement0) , "Price crosses below Retracement Line 0");
alert((price crosses above Retracement0) , "Price crosses above Retracement Line 0");
alert((price crosses below Retracement1) , "Price crosses below Retracement Line 1");
alert((price crosses above Retracement1) , "Price crosses above Retracement Line 1");
alert((price crosses below Retracement2) , "Price crosses below Retracement Line 2");
alert((price crosses above Retracement2) , "Price crosses above Retracement Line 2");
alert((price crosses below Retracement3) , "Price crosses below Retracement Line 3");
alert((price crosses above Retracement3) , "Price crosses above Retracement Line 3");
alert((price crosses below Retracement4) , "Price crosses below Retracement Line 4");
alert((price crosses above Retracement4) , "Price crosses above Retracement Line 4");
alert((price crosses below Retracement5) , "Price crosses below Retracement Line 5");
alert((price crosses above Retracement5) , "Price crosses above Retracement Line 5");
alert((price crosses below Retracement6) , "Price crosses below Retracement Line 6");
alert((price crosses above Retracement6) , "Price crosses above Retracement Line 6");
alert((price crosses below Retracement7) , "Price crosses below Retracement Line 7");
alert((price crosses above Retracement7) , "Price crosses above Retracement Line 7");
alert((price crosses below Retracement8) , "Price crosses below Retracement Line 8");
alert((price crosses above Retracement8) , "Price crosses above Retracement Line 8");
alert((price crosses below Retracement9) , "Price crosses below Retracement Line 9");
alert((price crosses above Retracement9) , "Price crosses above Retracement Line 9");
alert((price crosses below Retracement10) , "Price crosses below Retracement Line 10");
alert((price crosses above Retracement10) , "Price crosses above Retracement Line 10");
alert((price crosses below Retracement11) , "Price crosses below Retracement Line 11");
alert((price crosses above Retracement11) , "Price crosses above Retracement Line 11");
alert((price crosses below Retracement12) , "Price crosses below Retracement Line 12");
alert((price crosses above Retracement12) , "Price crosses above Retracement Line 12");
alert((price crosses below Retracement13) , "Price crosses below Retracement Line 13");
alert((price crosses above Retracement13) , "Price crosses above Retracement Line 13");
alert((price crosses below Retracement14) , "Price crosses below Retracement Line 14");
alert((price crosses above Retracement14) , "Price crosses above Retracement Line 14");
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
437 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top