From discussion found here: # https://usethinkscript.com/threads/highlight-three-candles-consecutively-making-higher-lows.12969/
can select any minimum quantity of higher low bars to look for.
(max is set by u=50)
options,
..change higher low bars color to violet
..draw dots under the higher low bars
....first bar is yellow, others are violet
..draw small yellow arrow above the first bar in series
EMR 15min 10/10/22
min qty set to 3
can select any minimum quantity of higher low bars to look for.
(max is set by u=50)
options,
..change higher low bars color to violet
..draw dots under the higher low bars
....first bar is yellow, others are violet
..draw small yellow arrow above the first bar in series
Code:
# hilows_xbars_01
# find any quantity of consecutive higher low bars
# https://usethinkscript.com/threads/highlight-three-candles-consecutively-making-higher-lows.12969/
# color bars of, higher lows, x in a row
#def bn = BarNumber();
def na = double.nan;
# used to check on 1st bar, look ahead
def t = if isnan(close[-1]) then 0 else if (low[0] < low[-1]) then 1 else 0;
# used on following bars, look back
def t2 = (low[1] < low[0]);
input qty_of_hilo_bars = 3;
def u = 50;
def x;
def x2;
if !t[1] and t then {
# first bar in series, check if enough bars
x = fold i = 1 to u
with p = 1
while !isnan(getvalue(close, -i)) and getvalue(t2, -i)
do p + 1;
x2 = if x >= qty_of_hilo_bars then x else 0;
} else if x2[1] > 0 then {
x = x[1] - 1;
x2 = x2[1] - 1;
} else {
x = 0;
x2 = 0;
}
def first = x2 > x2[1];
def hilo = (x2 > 0);
input change_bar_color = yes;
AssignPriceColor(if change_bar_color and hilo then Color.violet else Color.current);
input dots_on_higherlows = no;
plot d = if dots_on_higherlows and hilo then low*0.999 else na;
d.SetPaintingStrategy(PaintingStrategy.POINTS);
#d.SetDefaultColor(Color.cyan);
d.AssignValueColor(if first then color.yellow else if x2 > 0 then color.violet else color.dark_gray);
d.setlineweight(3);
d.hidebubble();
input small_arrow_on_first_higherlow = yes;
plot ar = if small_arrow_on_first_higherlow and first then 1 else 0;
ar.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up);
ar.SetDefaultColor(Color.yellow);
ar.setlineweight(3);
ar.hidebubble();
#------------------------------
input test1 = no;
addchartbubble(test1, low,
t + "\n" +
x + "\n" +
#qty_of_hilo_bars + "\n" +
x2
, (if first then color.yellow else if x2 > 0 then color.violet else color.dark_gray), no);
#
EMR 15min 10/10/22
min qty set to 3
Last edited by a moderator: