HiLo_ X Bars For ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
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


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
PsGL52c.jpg
 
Last edited by a moderator:
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


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
PsGL52c.jpg
Woah thanks a lot for this! I really appreciate your help.
 

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
347 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