richard_the_red_trendlines Chart Bubbles

545318

New member
Im having an issue with an indicator that uses debug to post a chart bubble with a number likely the angle and its aggresiveness related to price.


The snippet of the working bubble is this :

AddChartBubble(debug && bn == h2bn, th1, slope(h1bn, h1, bn, h), GlobalColor("Short_Color"));

I need this addchartbubble function instead of posting the debug values at each slope plot a white bubble labeled "Resistance" using plot "th1"

The stock I watch is futures or /ES on a 2 hour candle chart.



The code is riddled with hidebubble and hidetitle on each plot

I would like an example of a addchartbubble that works using the the selected function of slope without it requiring debug labeled "resistance" ive tried everything and nothing seems to work, removing all those instances of hide title or bubble, ive tried it all, im asking here as the final resort.

Note that addchartbubble is the only plot that works on the code nothing else ive tried posts on the indicator.

E


https://docs.google.com/document/d/1WwH1oKD3bzSCD9n0JPamvUS9pKW1UHm9XuVSQc6eU8o/edit
Code:
# richard_the_red_trendlines
# Draw automatic trendlines from peak to peak and/or low to low so you can see when trend breaks happen
# optionally show just upper or lower tls; show the points used; use body instead of wick; use alerts; change the line styles; and set the range to use for lookback distance


declare once_per_bar; # reduces computation time

input show_highs = yes; #hint show_highs: Show upper trendlines from peak to peak
input show_lows = yes; #hint show_lows: Show lower trendlines from trough to trough
input show_points = no; #hint show_points: show which bars are used to calculate the lines with a dot
input use_body_instead_of_wick = no; #hint use_body_instead_of_wick: Some people just want to watch the world burn
input show_first_bar_trend = no; #hint show_first_bar_trend: This is a neat feature that sometimes works amazingly and others is just chart clutter. It draws a line from the highest high or lowest low and the next bar; often if this trend is respected a little it gets respected a lot, and sometimes a ridiculous number of bars later.
def use_last_bar = no; #hint use_last_bar: Whether to ignore the current bar or not
input use_alert = no; #hint use_alert: Do a sound when the trendlines break
input line_style = Curve.FIRM; #hint line_style: Set all the line styles at once instead of plot-by-plot
input use_range = {default "Chart Range", "Days", "Bars"}; #hint use_range: Use the current chart range, a set number of days, or a set number of bars
input range = 100; #hint range: If you picked "Days" or "Bars" for use_range above, this is the value it will use for those

input debug = no;

def h = If (use_body_instead_of_wick, Max(open, close), high);
def l = If (use_body_instead_of_wick, Min(open, close), low);
def c = close;

def nan = Double.NaN;
def bn = BarNumber();
def islast = IsNaN(close[-1]) && !IsNaN(close);
def lastbn = HighestAll(If(islast, bn, nan));
def lastbnoffset = -lastbn + bn;
def lastbncheck = bn < lastbn + If (use_last_bar, 1, 0);
def ignore_last_bar = If (use_last_bar, yes, bn < lastbn);
def chart_scale = GetAggregationPeriod() / 1000 / 60; # minutes

def frombar;
def days = Min(lastbn, range * 16 * (60 / chart_scale));
switch (use_range) {
case "Days":
    frombar = days;
case "Bars":
    frombar = range;
default:
    frombar = lastbn;
}


DefineGlobalColor("high_color", CreateColor(107, 100, 72));
DefineGlobalColor("low_color", CreateColor(107, 100, 72));
DefineGlobalColor("high_dot_color", CreateColor(155, 145, 105));
DefineGlobalColor("low_dot_color", CreateColor(155, 145, 105));
#defineGlobalColor("off_color", createcolor(74, 66, 35));
#DefineGlobalColor("off_color", CreateColor(189, 71, 30));

script slope {
    input bar1 = 0;
    input price1 = 0;
    input bar2 = 0;
    input price2 = 0;
    plot slope = (price2 - price1) / (bar2 - bar1);
}

script trendline {
    input bar1 = 0;
    input price1 = 0;
    input bar2 = 0;
    input price2 = 0;
    def bn = BarNumber();
    plot tl = If(bn >= bar1, price2 + (bn - bar2) * slope(bar1, price1, bar2, price2), Double.NaN);
}


def h1c = If (bn > lastbn - frombar, If (IsNaN(h1c[1]) or h1c[1] <= 0 or h > h1c[1], h, h1c[1]), h1c[1]);
def h1 = GetValue(h1c, lastbnoffset);
def h1bn = HighestAll(If(h1 == h, bn, nan));
plot h1p = If (bn == h1bn && show_points, h1, nan); h1p.hideTitle(); h1p.hideBubble();
h1p.SetStyle(Curve.POINTS);
h1p.SetDefaultColor(GlobalColor("high_dot_color")); h1p.assignValueColor(GlobalColor("high_dot_color"));
h1p.SetLineWeight(1);
plot th0 = if show_first_bar_trend then trendline(h1bn, h1, h1bn + 1, HighestAll(If (bn[1] == h1bn, h, nan))) else nan;
th0.SetDefaultColor(GlobalColor("high_color")); th0.assignValueColor(GlobalColor("high_color"));
th0.SetStyle(Curve.LONG_DASH);
th0.SetLineWeight(2);

def h2s = If (ignore_last_bar && bn > h1bn, slope(h1bn, h1, bn, h), nan);
def h2 = HighestAll(If (lastbncheck && bn > h1bn && h2s == HighestAll(h2s), h, nan));
def h2bn = HighestAll(If(h2 == h, bn, nan));
plot h2p = If (bn == h2bn && show_points, h2, nan); h2p.hideTitle(); h2p.hideBubble();
h2p.SetStyle(Curve.POINTS);
h2p.SetDefaultColor(GlobalColor("high_dot_color")); h2p.assignValueColor(GlobalColor("high_dot_color"));
h2p.SetLineWeight(1);
def tlh1 = trendline(h1bn, h1, h2bn, h2);
plot th1 = if show_highs then tlh1 else nan;
th1.SetDefaultColor(GlobalColor("high_color")); th1.assignValueColor(GlobalColor("high_color"));
th1.SetStyle(line_style); th1.hideTitle(); th1.hideBubble();
th1.SetLineWeight(2);
addchartbubble(debug && bn == h2bn, th1, slope(h1bn, h1, bn, h), GlobalColor("high_color"));

def h3s = If (ignore_last_bar && bn > h2bn, slope(h2bn, h2, bn, h), nan);
def h3 = HighestAll(If (lastbncheck && bn > h2bn && h3s == HighestAll(h3s), h, nan));
def h3bn = HighestAll(If(h3 == h, bn, nan));
plot h3p = If (bn == h3bn && show_points, h3, nan); h3p.hideTitle(); h3p.hideBubble();
h3p.SetStyle(Curve.POINTS);
h3p.SetDefaultColor(GlobalColor("high_dot_color")); h3p.assignValueColor(GlobalColor("high_dot_color"));
h3p.SetLineWeight(1);
def tlh2 = trendline(h2bn, h2, h3bn, h3);
plot th2 = if show_highs then tlh2 else nan;
th2.SetDefaultColor(GlobalColor("high_color")); th2.assignValueColor(GlobalColor("high_color"));
th2.SetStyle(line_style); th2.hideTitle(); th2.hideBubble();
th2.SetLineWeight(2);
addchartbubble(debug && bn == h3bn, th2, slope(h2bn, h2, bn, h), GlobalColor("high_color"));

def h4s = If (ignore_last_bar && bn > h3bn, slope(h3bn, h3, bn, h), nan);
def h4 = HighestAll(If (lastbncheck && bn > h3bn && h4s == HighestAll(h4s), h, nan));
def h4bn = HighestAll(If(h4 == h, bn, nan));
plot h4p = If (bn == h4bn && show_points, h4, nan); h4p.hideTitle(); h4p.hideBubble();
h4p.SetStyle(Curve.POINTS);
h4p.SetDefaultColor(GlobalColor("high_dot_color")); h4p.assignValueColor(GlobalColor("high_dot_color"));
h4p.SetLineWeight(1);
def tlh3 = trendline(h3bn, h3, h4bn, h4);
plot th3 = if show_highs then tlh3 else nan;
th3.SetDefaultColor(GlobalColor("high_color")); th3.assignValueColor(GlobalColor("high_color"));
th3.SetStyle(line_style); th3.hideTitle(); th3.hideBubble();
addchartbubble(debug && bn == h4bn, th3, slope(h3bn, h3, bn, h), GlobalColor("high_color"));

def h5s = If (ignore_last_bar && bn > h4bn, slope(h4bn, h4, bn, h), nan);
def h5 = HighestAll(If (lastbncheck && bn > h4bn && h5s == HighestAll(h5s), h, nan));
def h5bn = HighestAll(If(h5 == h, bn, nan));
plot h5p = If (bn == h5bn && show_points, h5, nan); h5p.hideTitle(); h5p.hideBubble();
h5p.SetStyle(Curve.POINTS);
h5p.SetDefaultColor(GlobalColor("high_dot_color")); h5p.assignValueColor(GlobalColor("high_dot_color"));
h5p.SetLineWeight(1);
def tlh4 = trendline(h4bn, h4, h5bn, h5);
plot th4 = if show_highs then tlh4 else nan;
th4.SetDefaultColor(GlobalColor("high_color")); th4.assignValueColor(GlobalColor("high_color"));
th4.SetStyle(line_style); th4.hideTitle(); th4.hideBubble();
addchartbubble(debug && bn == h5bn, th4, slope(h4bn, h4, bn, h), GlobalColor("high_color"));

def h6s = If (ignore_last_bar && bn > h5bn, slope(h5bn, h5, bn, h), nan);
def h6 = HighestAll(If (lastbncheck && bn > h5bn && h6s == HighestAll(h6s), h, nan));
def h6bn = HighestAll(If(h6 == h, bn, nan));
plot h6p = If (bn == h6bn && show_points, h6, nan); h6p.hideTitle(); h6p.hideBubble();
h6p.SetStyle(Curve.POINTS);
h6p.SetDefaultColor(GlobalColor("high_dot_color")); h6p.assignValueColor(GlobalColor("high_dot_color"));
h6p.SetLineWeight(1);
def tlh5 = trendline(h5bn, h5, h6bn, h6);
plot th5 = if show_highs then tlh5 else nan;
th5.SetDefaultColor(GlobalColor("high_color")); th5.assignValueColor(GlobalColor("high_color"));
th5.SetStyle(line_style); th5.hideTitle(); th5.hideBubble();
addchartbubble(debug && bn == h6bn, th5, slope(h5bn, h5, bn, h), GlobalColor("high_color"));

def h7s = If (ignore_last_bar && bn > h6bn, slope(h6bn, h6, bn, h), nan);
def h7 = HighestAll(If (lastbncheck && bn > h6bn && h7s == HighestAll(h7s), h, nan));
def h7bn = HighestAll(If(h7 == h, bn, nan));
plot h7p = If (bn == h7bn && show_points, h7, nan); h7p.hideTitle(); h7p.hideBubble();
h7p.SetStyle(Curve.POINTS);
h7p.SetDefaultColor(GlobalColor("high_dot_color")); h7p.assignValueColor(GlobalColor("high_dot_color"));
h7p.SetLineWeight(1);
def tlh6 = trendline(h6bn, h6, h7bn, h7);
plot th6 = if show_highs then tlh6 else nan;
th6.SetDefaultColor(GlobalColor("high_color")); th6.assignValueColor(GlobalColor("high_color"));
th6.SetStyle(line_style); th6.hideTitle(); th6.hideBubble();
addchartbubble(debug && bn == h7bn, th6, slope(h6bn, h6, bn, h), GlobalColor("high_color"));

def h8s = If (ignore_last_bar && bn > h7bn, slope(h7bn, h7, bn, h), nan);
def h8 = HighestAll(If (lastbncheck && bn > h7bn && h8s == HighestAll(h8s), h, nan));
def h8bn = HighestAll(If(h8 == h, bn, nan));
plot h8p = If (bn == h8bn && show_points, h8, nan); h8p.hideTitle(); h8p.hideBubble();
h8p.SetStyle(Curve.POINTS);
h8p.SetDefaultColor(GlobalColor("high_dot_color")); h8p.assignValueColor(GlobalColor("high_dot_color"));
h8p.SetLineWeight(1);
def tlh7 = trendline(h7bn, h7, h8bn, h8);
plot th7 = if show_highs then tlh7 else nan;
th7.SetDefaultColor(GlobalColor("high_color")); th7.assignValueColor(GlobalColor("high_color"));
th7.SetStyle(line_style); th7.hideTitle(); th7.hideBubble();
addchartbubble(debug && bn == h8bn, th7, slope(h7bn, h7, bn, h), GlobalColor("high_color"));

def h9s = If (ignore_last_bar && bn > h8bn, slope(h8bn, h8, bn, h), nan);
def h9 = HighestAll(If (lastbncheck && bn > h8bn && h9s == HighestAll(h9s), h, nan));
def h9bn = HighestAll(If(h9 == h, bn, nan));
plot h9p = If (bn == h9bn && show_points, h9, nan); h9p.hideTitle(); h9p.hideBubble();
h9p.SetStyle(Curve.POINTS);
h9p.SetDefaultColor(GlobalColor("high_dot_color")); h9p.assignValueColor(GlobalColor("high_dot_color"));
h9p.SetLineWeight(1);
def tlh8 = trendline(h8bn, h8, h9bn, h9);
plot th8 = if show_highs then tlh8 else nan;
th8.SetDefaultColor(GlobalColor("high_color")); th8.assignValueColor(GlobalColor("high_color"));
th8.SetStyle(line_style); th8.hideTitle(); th8.hideBubble();
addchartbubble(debug && bn == h9bn, th8, slope(h8bn, h8, bn, h), GlobalColor("high_color"));

def h10s = If (ignore_last_bar && bn > h9bn, slope(h9bn, h9, bn, h), nan);
def h10 = HighestAll(If (lastbncheck && bn > h9bn && h10s == HighestAll(h10s), h, nan));
def h10bn = HighestAll(If(h10 == h, bn, nan));
plot h10p = If (bn == h10bn && show_points, h10, nan); h10p.hideTitle(); h10p.hideBubble();
h10p.SetStyle(Curve.POINTS);
h10p.SetDefaultColor(GlobalColor("high_dot_color")); h10p.assignValueColor(GlobalColor("high_dot_color"));
h10p.SetLineWeight(1);
def tlh9 = trendline(h9bn, h9, h10bn, h10);
plot th9 = if show_highs then tlh9 else nan;
th9.SetDefaultColor(GlobalColor("high_color")); th9.assignValueColor(GlobalColor("high_color"));
th9.SetStyle(line_style); th9.hideTitle(); th9.hideBubble();
addchartbubble(debug && bn == h10bn, th9, slope(h9bn, h9, bn, h), GlobalColor("high_color"));

def h11s = If (ignore_last_bar && bn > h10bn, slope(h10bn, h10, bn, h), nan);
def h11 = HighestAll(If (lastbncheck && bn > h10bn && h11s == HighestAll(h11s), h, nan));
def h11bn = HighestAll(If(h11 == h, bn, nan));
plot h11p = If (bn == h11bn && show_points, h11, nan); h11p.hideTitle(); h11p.hideBubble();
h11p.SetStyle(Curve.POINTS);
h11p.SetDefaultColor(GlobalColor("high_dot_color")); h11p.assignValueColor(GlobalColor("high_dot_color"));
h11p.SetLineWeight(1);
def tlh10 = trendline(h10bn, h10, h11bn, h11);
plot th10 = if show_highs then tlh10 else nan;
th10.SetDefaultColor(GlobalColor("high_color")); th10.assignValueColor(GlobalColor("high_color"));
th10.SetStyle(line_style); th10.hideTitle(); th10.hideBubble();
addchartbubble(debug && bn == h11bn, th10, slope(h10bn, h10, bn, h), GlobalColor("high_color"));

def h12s = If (ignore_last_bar && bn > h11bn, slope(h11bn, h11, bn, h), nan);
def h12 = HighestAll(If (lastbncheck && bn > h11bn && h12s == HighestAll(h12s), h, nan));
def h12bn = HighestAll(If(h12 == h, bn, nan));
plot h12p = If (bn == h12bn && show_points, h12, nan); h12p.hideTitle(); h12p.hideBubble();
h12p.SetStyle(Curve.POINTS);
h12p.SetDefaultColor(GlobalColor("high_dot_color")); h12p.assignValueColor(GlobalColor("high_dot_color"));
h12p.SetLineWeight(1);
def tlh11 = trendline(h11bn, h11, h12bn, h12);
plot th11 = if show_highs then tlh11 else nan;
th11.SetDefaultColor(GlobalColor("high_color")); th11.assignValueColor(GlobalColor("high_color"));
th11.SetStyle(line_style); th11.hideTitle(); th11.hideBubble();
addchartbubble(debug && bn == h12bn, th11, slope(h11bn, h11, bn, h), GlobalColor("high_color"));

def h13s = If (ignore_last_bar && bn > h12bn, slope(h12bn, h12, bn, h), nan);
def h13 = HighestAll(If (lastbncheck && bn > h12bn && h13s == HighestAll(h13s), h, nan));
def h13bn = HighestAll(If(h13 == h, bn, nan));
plot h13p = If (bn == h13bn && show_points, h13, nan); h13p.hideTitle(); h13p.hideBubble();
h13p.SetStyle(Curve.POINTS);
h13p.SetDefaultColor(GlobalColor("high_dot_color")); h13p.assignValueColor(GlobalColor("high_dot_color"));
h13p.SetLineWeight(1);
def tlh12 = trendline(h12bn, h12, h13bn, h13);
plot th12 = if show_highs then tlh12 else nan;
th12.SetDefaultColor(GlobalColor("high_color")); th12.assignValueColor(GlobalColor("high_color"));
th12.SetStyle(line_style); th12.hideTitle(); th12.hideBubble();
addchartbubble(debug && bn == h13bn, th12, slope(h12bn, h12, bn, h), GlobalColor("high_color"));

def h14s = If (ignore_last_bar && bn > h13bn, slope(h13bn, h13, bn, h), nan);
def h14 = HighestAll(If (lastbncheck && bn > h13bn && h14s == HighestAll(h14s), h, nan));
def h14bn = HighestAll(If(h14 == h, bn, nan));
plot h14p = If (bn == h14bn && show_points, h14, nan); h14p.hideTitle(); h14p.hideBubble();
h14p.SetStyle(Curve.POINTS);
h14p.SetDefaultColor(GlobalColor("high_dot_color")); h14p.assignValueColor(GlobalColor("high_dot_color"));
h14p.SetLineWeight(1);
def tlh13 = trendline(h13bn, h13, h14bn, h14);
plot th13 = if show_highs then tlh13 else nan;
th13.SetDefaultColor(GlobalColor("high_color")); th13.assignValueColor(GlobalColor("high_color"));
th13.SetStyle(line_style); th13.hideTitle(); th13.hideBubble();
addchartbubble(debug && bn == h14bn, th13, slope(h13bn, h13, bn, h), GlobalColor("high_color"));

def h15s = If (ignore_last_bar && bn > h14bn, slope(h14bn, h14, bn, h), nan);
def h15 = HighestAll(If (lastbncheck && bn > h14bn && h15s == HighestAll(h15s), h, nan));
def h15bn = HighestAll(If(h15 == h, bn, nan));
plot h15p = If (bn == h15bn && show_points, h15, nan); h15p.hideTitle(); h15p.hideBubble();
h15p.SetStyle(Curve.POINTS);
h15p.SetDefaultColor(GlobalColor("high_dot_color")); h15p.assignValueColor(GlobalColor("high_dot_color"));
h15p.SetLineWeight(1);
def tlh14 = trendline(h14bn, h14, h15bn, h15);
plot th14 = if show_highs then tlh14 else nan;
th14.SetDefaultColor(GlobalColor("high_color")); th14.assignValueColor(GlobalColor("high_color"));
th14.SetStyle(line_style); th14.hideTitle(); th14.hideBubble();
addchartbubble(debug && bn == h15bn, th14, slope(h14bn, h14, bn, h), GlobalColor("high_color"));



def l1c = If (bn > lastbn - frombar, If (IsNaN(l1c[1]) or l1c[1] <= 0 or l < l1c[1], l, l1c[1]), l1c[1]);
def l1 = GetValue(l1c, lastbnoffset);
def l1bn = HighestAll(If(l1 == l, bn, nan));
plot l1p = If (bn == l1bn && show_points, l1, nan); l1p.hideTitle(); l1p.hideBubble();
l1p.SetStyle(Curve.POINTS);
l1p.SetDefaultColor(GlobalColor("low_dot_color")); l1p.assignValueColor(GlobalColor("low_dot_color"));
l1p.SetLineWeight(1);
plot tl0 = if show_first_bar_trend then trendline(l1bn, l1, l1bn + 1, HighestAll(If (bn[1] == l1bn, l, nan))) else nan;
tl0.SetDefaultColor(GlobalColor("low_color")); tl0.assignValueColor(GlobalColor("low_color"));
tl0.SetStyle(Curve.LONG_DASH);
tl0.SetLineWeight(2);

def l2s = If (ignore_last_bar && bn > l1bn, slope(l1bn, l1, bn, l), nan);
def l2 = LowestAll(If (lastbncheck && bn > l1bn && l2s == LowestAll(l2s), l, nan));
def l2bn = HighestAll(If(l2 == l, bn, nan));
plot l2p = If (bn == l2bn && show_points, l2, nan); l2p.hideTitle(); l2p.hideBubble();
l2p.SetStyle(Curve.POINTS);
l2p.SetDefaultColor(GlobalColor("low_dot_color")); l2p.assignValueColor(GlobalColor("low_dot_color"));
l2p.SetLineWeight(1);
def tll1 = trendline(l1bn, l1, l2bn, l2);
plot tl1 = if show_lows then tll1 else nan;
tl1.SetDefaultColor(GlobalColor("low_color")); tl1.assignValueColor(GlobalColor("low_color"));
tl1.SetStyle(line_style); tl1.hideTitle(); tl1.hideBubble();
tl1.SetLineWeight(2);
addchartbubble(debug && bn == l2bn, tl1, slope(l1bn, l1, bn, l), GlobalColor("low_color"), no);

def l3s = If (ignore_last_bar && bn > l2bn, slope(l2bn, l2, bn, l), nan);
def l3 = LowestAll(If (lastbncheck && bn > l2bn && l3s == LowestAll(l3s), l, nan));
def l3bn = HighestAll(If(l3 == l, bn, nan));
plot l3p = If (bn == l3bn && show_points, l3, nan); l3p.hideTitle(); l3p.hideBubble();
l3p.SetStyle(Curve.POINTS);
l3p.SetDefaultColor(GlobalColor("low_dot_color")); l3p.assignValueColor(GlobalColor("low_dot_color"));
l3p.SetLineWeight(1);
def tll2 = trendline(l2bn, l2, l3bn, l3);
plot tl2 = if show_lows then tll2 else nan;
tl2.SetDefaultColor(GlobalColor("low_color")); tl2.assignValueColor(GlobalColor("low_color"));
tl2.SetStyle(line_style); tl2.hideTitle(); tl2.hideBubble();
tl2.SetLineWeight(2);
addchartbubble(debug && bn == l3bn, tl2, slope(l2bn, l2, bn, l), GlobalColor("low_color"), no);

def l4s = If (ignore_last_bar && bn > l3bn, slope(l3bn, l3, bn, l), nan);
def l4 = LowestAll(If (lastbncheck && bn > l3bn && l4s == LowestAll(l4s), l, nan));
def l4bn = HighestAll(If(l4 == l, bn, nan));
plot l4p = If (bn == l4bn && show_points, l4, nan); l4p.hideTitle(); l4p.hideBubble();
l4p.SetStyle(Curve.POINTS);
l4p.SetDefaultColor(GlobalColor("low_dot_color")); l4p.assignValueColor(GlobalColor("low_dot_color"));
l4p.SetLineWeight(1);
def tll3 = trendline(l3bn, l3, l4bn, l4);
plot tl3 = if show_lows then tll3 else nan;
tl3.SetDefaultColor(GlobalColor("low_color")); tl3.assignValueColor(GlobalColor("low_color"));
tl3.SetStyle(line_style); tl3.hideTitle(); tl3.hideBubble();
addchartbubble(debug && bn == l4bn, tl3, slope(l3bn, l3, bn, l), GlobalColor("low_color"), no);

def l5s = If (ignore_last_bar && bn > l4bn, slope(l4bn, l4, bn, l), nan);
def l5 = LowestAll(If (lastbncheck && bn > l4bn && l5s == LowestAll(l5s), l, nan));
def l5bn = HighestAll(If(l5 == l, bn, nan));
plot l5p = If (bn == l5bn && show_points, l5, nan); l5p.hideTitle(); l5p.hideBubble();
l5p.SetStyle(Curve.POINTS);
l5p.SetDefaultColor(GlobalColor("low_dot_color")); l5p.assignValueColor(GlobalColor("low_dot_color"));
l5p.SetLineWeight(1);
def tll4 = trendline(l4bn, l4, l5bn, l5);
plot tl4 = if show_lows then tll4 else nan;
tl4.SetDefaultColor(GlobalColor("low_color")); tl4.assignValueColor(GlobalColor("low_color"));
tl4.SetStyle(line_style); tl4.hideTitle(); tl4.hideBubble();
addchartbubble(debug && bn == l5bn, tl4, slope(l4bn, l4, bn, l), GlobalColor("low_color"), no);

def l6s = If (ignore_last_bar && bn > l5bn, slope(l5bn, l5, bn, l), nan);
def l6 = LowestAll(If (lastbncheck && bn > l5bn && l6s == LowestAll(l6s), l, nan));
def l6bn = HighestAll(If(l6 == l, bn, nan));
plot l6p = If (bn == l6bn && show_points, l6, nan); l6p.hideTitle(); l6p.hideBubble();
l6p.SetStyle(Curve.POINTS);
l6p.SetDefaultColor(GlobalColor("low_dot_color")); l6p.assignValueColor(GlobalColor("low_dot_color"));
l6p.SetLineWeight(1);
def tll5 = trendline(l5bn, l5, l6bn, l6);
plot tl5 = if show_lows then tll5 else nan;
tl5.SetDefaultColor(GlobalColor("low_color")); tl5.assignValueColor(GlobalColor("low_color"));
tl5.SetStyle(line_style); tl5.hideTitle(); tl5.hideBubble();
addchartbubble(debug && bn == l6bn, tl5, slope(l5bn, l5, bn, l), GlobalColor("low_color"), no);

def l7s = If (ignore_last_bar && bn > l6bn, slope(l6bn, l6, bn, l), nan);
def l7 = LowestAll(If (lastbncheck && bn > l6bn && l7s == LowestAll(l7s), l, nan));
def l7bn = HighestAll(If(l7 == l, bn, nan));
plot l7p = If (bn == l7bn && show_points, l7, nan); l7p.hideTitle(); l7p.hideBubble();
l7p.SetStyle(Curve.POINTS);
l7p.SetDefaultColor(GlobalColor("low_dot_color")); l7p.assignValueColor(GlobalColor("low_dot_color"));
l7p.SetLineWeight(1);
def tll6 = trendline(l6bn, l6, l7bn, l7);
plot tl6 = if show_lows then tll6 else nan;
tl6.SetDefaultColor(GlobalColor("low_color")); tl6.assignValueColor(GlobalColor("low_color"));
tl6.SetStyle(line_style); tl6.hideTitle(); tl6.hideBubble();
addchartbubble(debug && bn == l7bn, tl6, slope(l6bn, l6, bn, l), GlobalColor("low_color"), no);

def l8s = If (ignore_last_bar && bn > l7bn, slope(l7bn, l7, bn, l), nan);
def l8 = LowestAll(If (lastbncheck && bn > l7bn && l8s == LowestAll(l8s), l, nan));
def l8bn = HighestAll(If(l8 == l, bn, nan));
plot l8p = If (bn == l8bn && show_points, l8, nan); l8p.hideTitle(); l8p.hideBubble();
l8p.SetStyle(Curve.POINTS);
l8p.SetDefaultColor(GlobalColor("low_dot_color")); l8p.assignValueColor(GlobalColor("low_dot_color"));
l8p.SetLineWeight(1);
def tll7 = trendline(l7bn, l7, l8bn, l8);
plot tl7 = if show_lows then tll7 else nan;
tl7.SetDefaultColor(GlobalColor("low_color")); tl7.assignValueColor(GlobalColor("low_color"));
tl7.SetStyle(line_style); tl7.hideTitle(); tl7.hideBubble();
addchartbubble(debug && bn == l8bn, tl7, slope(l7bn, l7, bn, l), GlobalColor("low_color"), no);

def l9s = If (ignore_last_bar && bn > l8bn, slope(l8bn, l8, bn, l), nan);
def l9 = LowestAll(If (lastbncheck && bn > l8bn && l9s == LowestAll(l9s), l, nan));
def l9bn = HighestAll(If(l9 == l, bn, nan));
plot l9p = If (bn == l9bn && show_points, l9, nan); l9p.hideTitle(); l9p.hideBubble();
l9p.SetStyle(Curve.POINTS);
l9p.SetDefaultColor(GlobalColor("low_dot_color")); l9p.assignValueColor(GlobalColor("low_dot_color"));
l9p.SetLineWeight(1);
def tll8 = trendline(l8bn, l8, l9bn, l9);
plot tl8 = if show_lows then tll8 else nan;
tl8.SetDefaultColor(GlobalColor("low_color")); tl8.assignValueColor(GlobalColor("low_color"));
tl8.SetStyle(line_style); tl8.hideTitle(); tl8.hideBubble();
addchartbubble(debug && bn == l9bn, tl8, slope(l8bn, l8, bn, l), GlobalColor("low_color"), no);

def l10s = If (ignore_last_bar && bn > l9bn, slope(l9bn, l9, bn, l), nan);
def l10 = LowestAll(If (lastbncheck && bn > l9bn && l10s == LowestAll(l10s), l, nan));
def l10bn = HighestAll(If(l10 == l, bn, nan));
plot l10p = If (bn == l10bn && show_points, l10, nan); l10p.hideTitle(); l10p.hideBubble();
l10p.SetStyle(Curve.POINTS);
l10p.SetDefaultColor(GlobalColor("low_dot_color")); l10p.assignValueColor(GlobalColor("low_dot_color"));
l10p.SetLineWeight(1);
def tll9 = trendline(l9bn, l9, l10bn, l10);
plot tl9 = if show_lows then tll9 else nan;
tl9.SetDefaultColor(GlobalColor("low_color")); tl9.assignValueColor(GlobalColor("low_color"));
tl9.SetStyle(line_style); tl9.hideTitle(); tl9.hideBubble();
addchartbubble(debug && bn == l10bn, tl9, slope(l9bn, l9, bn, l), GlobalColor("low_color"), no);

def l11s = If (ignore_last_bar && bn > l10bn, slope(l10bn, l10, bn, l), nan);
def l11 = LowestAll(If (lastbncheck && bn > l10bn && l11s == LowestAll(l11s), l, nan));
def l11bn = HighestAll(If(l11 == l, bn, nan));
plot l11p = If (bn == l11bn && show_points, l11, nan); l11p.hideTitle(); l11p.hideBubble();
l11p.SetStyle(Curve.POINTS);
l11p.SetDefaultColor(GlobalColor("low_dot_color")); l11p.assignValueColor(GlobalColor("low_dot_color"));
l11p.SetLineWeight(1);
def tll10 = trendline(l10bn, l10, l11bn, l11);
plot tl10 = if show_lows then tll10 else nan;
tl10.SetDefaultColor(GlobalColor("low_color")); tl10.assignValueColor(GlobalColor("low_color"));
tl10.SetStyle(line_style); tl10.hideTitle(); tl10.hideBubble();
addchartbubble(debug && bn == l11bn, tl10, slope(l10bn, l10, bn, l), GlobalColor("low_color"), no);

def l12s = If (ignore_last_bar && bn > l11bn, slope(l11bn, l10, bn, l), nan);
def l12 = LowestAll(If (lastbncheck && bn > l11bn && l12s == LowestAll(l12s), l, nan));
def l12bn = HighestAll(If(l12 == l, bn, nan));
plot l12p = If (bn == l12bn && show_points, l12, nan); l12p.hideTitle(); l12p.hideBubble();
l12p.SetStyle(Curve.POINTS);
l12p.SetDefaultColor(GlobalColor("low_dot_color")); l12p.assignValueColor(GlobalColor("low_dot_color"));
l12p.SetLineWeight(1);
def tll11 = trendline(l11bn, l10, l12bn, l12);
plot tl11 = if show_lows then tll10 else nan;
tl11.SetDefaultColor(GlobalColor("low_color")); tl11.assignValueColor(GlobalColor("low_color"));
tl11.SetStyle(line_style); tl11.hideTitle(); tl11.hideBubble();
addchartbubble(debug && bn == l12bn, tl10, slope(l11bn, l10, bn, l), GlobalColor("low_color"), no);

def l13s = If (ignore_last_bar && bn > l12bn, slope(l12bn, l12, bn, l), nan);
def l13 = LowestAll(If (lastbncheck && bn > l12bn && l13s == LowestAll(l13s), l, nan));
def l13bn = HighestAll(If(l13 == l, bn, nan));
plot l13p = If (bn == l13bn && show_points, l13, nan); l13p.hideTitle(); l13p.hideBubble();
l13p.SetStyle(Curve.POINTS);
l13p.SetDefaultColor(GlobalColor("low_dot_color")); l13p.assignValueColor(GlobalColor("low_dot_color"));
l13p.SetLineWeight(1);
def tll12 = trendline(l12bn, l12, l13bn, l13);
plot tl12 = if show_lows then tll12 else nan;
tl12.SetDefaultColor(GlobalColor("low_color")); tl12.assignValueColor(GlobalColor("low_color"));
tl12.SetStyle(line_style); tl12.hideTitle(); tl12.hideBubble();
addchartbubble(debug && bn == l13bn, tl12, slope(l12bn, l12, bn, l), GlobalColor("low_color"), no);

def l14s = If (ignore_last_bar && bn > l13bn, slope(l13bn, l13, bn, l), nan);
def l14 = LowestAll(If (lastbncheck && bn > l13bn && l14s == LowestAll(l14s), l, nan));
def l14bn = HighestAll(If(l14 == l, bn, nan));
plot l14p = If (bn == l14bn && show_points, l14, nan); l14p.hideTitle(); l14p.hideBubble();
l14p.SetStyle(Curve.POINTS);
l14p.SetDefaultColor(GlobalColor("low_dot_color")); l14p.assignValueColor(GlobalColor("low_dot_color"));
l14p.SetLineWeight(1);
def tll13 = trendline(l13bn, l13, l14bn, l14);
plot tl13 = if show_lows then tll13 else nan;
tl13.SetDefaultColor(GlobalColor("low_color")); tl13.assignValueColor(GlobalColor("low_color"));
tl13.SetStyle(line_style); tl13.hideTitle(); tl13.hideBubble();
addchartbubble(debug && bn == l14bn, tl13, slope(l13bn, l13, bn, l), GlobalColor("low_color"), no);

def l15s = If (ignore_last_bar && bn > l14bn, slope(l14bn, l14, bn, l), nan);
def l15 = LowestAll(If (lastbncheck && bn > l14bn && l15s == LowestAll(l15s), l, nan));
def l15bn = HighestAll(If(l15 == l, bn, nan));
plot l15p = If (bn == l15bn && show_points, l15, nan); l15p.hideTitle(); l15p.hideBubble();
l15p.SetStyle(Curve.POINTS);
l15p.SetDefaultColor(GlobalColor("low_dot_color")); l15p.assignValueColor(GlobalColor("low_dot_color"));
l15p.SetLineWeight(1);
def tll14 = trendline(l14bn, l14, l15bn, l15);
plot tl14 = if show_lows then tll14 else nan;
tl14.SetDefaultColor(GlobalColor("low_color")); tl14.assignValueColor(GlobalColor("low_color"));
tl14.SetStyle(line_style); tl14.hideTitle(); tl14.hideBubble();
addchartbubble(debug && bn == l15bn, tl14, slope(l14bn, l14, bn, l), GlobalColor("low_color"), no);


Alert(use_alert && show_highs && c > th0 && th1 && c[1] <= th0[1], "upper trendline break (th0)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th1 && th2 && c[1] <= th1[1], "upper trendline break (th1)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th2 && th3 && c[1] <= th2[1], "upper trendline break (th2)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th3 && th4 && c[1] <= th3[1], "upper trendline break (th3)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th4 && th5 && c[1] <= th4[1], "upper trendline break (th4)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th5 && th6 && c[1] <= th5[1], "upper trendline break (th5)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th6 && th7 && c[1] <= th6[1], "upper trendline break (th6)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th7 && th8 && c[1] <= th7[1], "upper trendline break (th7)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th8 && th9 && c[1] <= th8[1], "upper trendline break (th8)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th9  && th10&& c[1] <= th9[1], "upper trendline break (th9)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th10 && th11 && c[1] <= th10[1], "upper trendline break (th10)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th11 && th12 && c[1] <= th11[1], "upper trendline break (th11)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th12 && th13 && c[1] <= th12[1], "upper trendline break (th12)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_highs && c > th13 && th14 && c[1] <= th13[1], "upper trendline break (th13)", Alert.BAR, Sound.Ding);
#Alert(use_alert && show_highs && c > th14 && th15 && c[1] <= th14[1], "upper trendline break (th14)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl0 && tl1 && c[1] >= tl0[1], "lower trendline break (tl0)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl1 && tl2 && c[1] >= tl1[1], "lower trendline break (tl1)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl2 && tl3 && c[1] >= tl2[1], "lower trendline break (tl2)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl3 && tl4 && c[1] >= tl3[1], "lower trendline break (tl3)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl4 && tl5 && c[1] >= tl4[1], "lower trendline break (tl4)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl5 && tl6 && c[1] >= tl5[1], "lower trendline break (tl5)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl6 && tl7 && c[1] >= tl6[1], "lower trendline break (tl6)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl7 && tl8 && c[1] >= tl7[1], "lower trendline break (tl7)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl8 && tl9 && c[1] >= tl8[1], "lower trendline break (tl8)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl9  && tl10&& c[1] >= tl9[1], "lower trendline break (tl9)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl10 && tl11 && c[1] >= tl10[1], "lower trendline break (tl10)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl11 && tl12 && c[1] >= tl11[1], "lower trendline break (tl11)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl12 && tl13 && c[1] >= tl12[1], "lower trendline break (tl12)", Alert.BAR, Sound.Ding);
Alert(use_alert && show_lows && c < tl13 && tl14 && c[1] >= tl13[1], "lower trendline break (tl13)", Alert.BAR, Sound.Ding);
#Alert(use_alert && show_lows && c < tl14 && c[1] >= tl14[1], "lower trendline break (tl14)", Alert.BAR, Sound.Ding);
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
379 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