Time Based Range Label

TonXas

New member
Any way to put the WT label underneath the bottom left of the range box?
Code:
# inputs
input orStartTime = 1700;
input orEndTime = 0100;
input period = AggregationPeriod.FOUR_HOURS;
input showOnlyToday = no;
input showOnlyToday_boxes = yes;
input showCloud = yes;
input showboxes = yes;
input showMidpoint = yes;
input useAlerts = yes;
input useTradeSignals = no;
input day_of_week = {default Sunday};
# constants
def na = Double.NaN;
def hi = high(period = period);
def lo = low(period = period);
DefineGlobalColor("Cloud", Color.GRAY);

# opening range time logic
def overnight = orStartTime > orEndTime;
def pastORstart = SecondsFromTime(orStartTime) >= 0;
def beforeORend = SecondsTillTime(orEndTime) > 0;
def isOR =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
def isOR2 =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
#def isOr = SecondsTillTime(orEndTime) > 0 and SecondsFromTime(orStartTime) >= 0;
def today = (!showOnlyToday or GetDay() == GetLastDay()) and !IsNaN(close);
def today2 = (!showOnlyToday_boxes or GetDay() == GetLastDay()) and !IsNaN(close);
# opening range levels logic
def orhi =
    if orhi[1] == 0
        or !isOR[1]
        and isOR
    then hi
    else if isOR
        and hi > orhi[1]
    then hi
    else orhi[1];

def orlo =
    if orlo[1] == 0
        or !isOR[1]
        and isOR
    then lo
    else if isOR
        and lo < orlo[1]
    then lo
    else orlo[1];

# opening range levels logic
def orhi2 =
    if orhi2[1] == 0
        or !isOR2[1]
        and isOR2
    then hi
    else if isOR2
        and hi > orhi2[1]
    then hi
    else orhi2[1];

def orlo2 =
    if orlo2[1] == 0
        or !isOR2[1]
        and isOR2
    then lo
    else if isOR2
        and lo < orlo2[1]
    then lo
    else orlo2[1];
# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOR then (orh + orl) / 2 else na;

def orh2 = if today2 < 1 then na else orhi2;
def orl2 = if today2 < 1 then na else orlo2;

orm.SetHiding(!showMidpoint);


def range = orhi - orlo;

plot SHH25 = orh2 + .0025;
plot SHH50 = orh2 + .005;
plot SHL25 = orl2 - .0025;
plot SHL50 = orl2 - .005;
SHH25.Hide();
SHL25.Hide();
SHH50.Hide();
SHL50.Hide();
AddCloud(if showCloud and isOR then orh else na, if showCloud and isOR then orl else na, GlobalColor("cloud"), GlobalColor("cloud"));
AddCloud(if !showboxes then na else SHH50, SHH25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
AddCloud(if !showboxes then na else SHL50, SHL25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
# look and feel
orh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orm.SetPaintingStrategy(PaintingStrategy.DASHES);

orh.SetDefaultColor(Color.WHITE);
orl.SetDefaultColor(Color.WHITE);
orm.SetDefaultColor(Color.WHITE);

plot highBreak = useTradeSignals and !isOR and close crosses above orh;
plot highBreaklow = useTradeSignals and !isOR and close crosses below orh;
plot lowBreak = useTradeSignals and !isOR and close crosses below orl;
plot lowBreakhigh = useTradeSignals and !isOR and close crosses above orl;
plot midhighbreak = useTradeSignals and !isOR and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOR and close crosses below orm;
highBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
highBreaklow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreakhigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midhighbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midlowbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
highBreak.SetDefaultColor(Color.DARK_GREEN);
lowBreak.SetDefaultColor(Color.DARK_RED);
midhighbreak.SetDefaultColor(Color.DARK_GREEN);
midlowbreak.SetDefaultColor(Color.DARK_RED);
Alert(useAlerts and highBreak, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and highBreaklow, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreak, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreakhigh, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midhighbreak, "ORM Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midlowbreak, "ORM Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);



AddLabel(close > 0, Concat( "WT: ", (orhi - orlo) * 10000), Color.CYAN);
#plot WT = if today == (orhi - orlo) then orlo - (3 * TickSize()) else Double.NaN;
#AddChartBubble(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);
 
not sure if i put the bubbles in the desired place. i don't see any boxes, just lines.
bubbles will be always shown. i didn't add code to turn them off.
i looked for a change in value of the lower cloud line, and placed a bubble there.

i don't know what WT is, i didn't verify the data. i just placed the data in a bubble.
have to have ext hours on to see this

Ruby:
# rangebox_01

# turn on ext hours

# inputs
input orStartTime = 1700;
input orEndTime = 0100;
input period = AggregationPeriod.FOUR_HOURS;
input showOnlyToday = no;
input showOnlyToday_boxes = yes;
input showCloud = yes;
input showboxes = yes;
input showMidpoint = yes;
input useAlerts = yes;
input useTradeSignals = no;
input day_of_week = {default Sunday};
# constants
def na = Double.NaN;
def hi = high(period = period);
def lo = low(period = period);
DefineGlobalColor("Cloud", Color.GRAY);

# opening range time logic
def overnight = orStartTime > orEndTime;
def pastORstart = SecondsFromTime(orStartTime) >= 0;
def beforeORend = SecondsTillTime(orEndTime) > 0;
def isOR =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
def isOR2 =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
#def isOr = SecondsTillTime(orEndTime) > 0 and SecondsFromTime(orStartTime) >= 0;
def today = (!showOnlyToday or GetDay() == GetLastDay()) and !IsNaN(close);
def today2 = (!showOnlyToday_boxes or GetDay() == GetLastDay()) and !IsNaN(close);
# opening range levels logic
def orhi =
    if orhi[1] == 0
        or !isOR[1]
        and isOR
    then hi
    else if isOR
        and hi > orhi[1]
    then hi
    else orhi[1];

def orlo =
    if orlo[1] == 0
        or !isOR[1]
        and isOR
    then lo
    else if isOR
        and lo < orlo[1]
    then lo
    else orlo[1];

# opening range levels logic
def orhi2 =
    if orhi2[1] == 0
        or !isOR2[1]
        and isOR2
    then hi
    else if isOR2
        and hi > orhi2[1]
    then hi
    else orhi2[1];

def orlo2 =
    if orlo2[1] == 0
        or !isOR2[1]
        and isOR2
    then lo
    else if isOR2
        and lo < orlo2[1]
    then lo
    else orlo2[1];
# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOR then (orh + orl) / 2 else na;

def orh2 = if today2 < 1 then na else orhi2;
def orl2 = if today2 < 1 then na else orlo2;

orm.SetHiding(!showMidpoint);


def range = orhi - orlo;

plot SHH25 = orh2 + .0025;
plot SHH50 = orh2 + .005;
plot SHL25 = orl2 - .0025;
plot SHL50 = orl2 - .005;
SHH25.Hide();
SHL25.Hide();
SHH50.Hide();
SHL50.Hide();
AddCloud(if showCloud and isOR then orh else na, if showCloud and isOR then orl else na, GlobalColor("cloud"), GlobalColor("cloud"));
AddCloud(if !showboxes then na else SHH50, SHH25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
AddCloud(if !showboxes then na else SHL50, SHL25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
# look and feel
orh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orm.SetPaintingStrategy(PaintingStrategy.DASHES);

orh.SetDefaultColor(Color.WHITE);
orl.SetDefaultColor(Color.WHITE);
orm.SetDefaultColor(Color.WHITE);

plot highBreak = useTradeSignals and !isOR and close crosses above orh;
plot highBreaklow = useTradeSignals and !isOR and close crosses below orh;
plot lowBreak = useTradeSignals and !isOR and close crosses below orl;
plot lowBreakhigh = useTradeSignals and !isOR and close crosses above orl;
plot midhighbreak = useTradeSignals and !isOR and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOR and close crosses below orm;
highBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
highBreaklow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreakhigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midhighbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midlowbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
highBreak.SetDefaultColor(Color.DARK_GREEN);
lowBreak.SetDefaultColor(Color.DARK_RED);
midhighbreak.SetDefaultColor(Color.DARK_GREEN);
midlowbreak.SetDefaultColor(Color.DARK_RED);
Alert(useAlerts and highBreak, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and highBreaklow, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreak, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreakhigh, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midhighbreak, "ORM Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midlowbreak, "ORM Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);


def wt = (orhi - orlo) * 10000;
AddLabel(close > 0, Concat( "WT: ", (orhi - orlo) * 10000), Color.CYAN);
#plot WT = if today == (orhi - orlo) then orlo - (3 * TickSize()) else Double.NaN;
#AddChartBubble(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);

def bub = if (orl[1] <> orl) then 1 else 0;
#plot z = if bub then orl else na;
#z.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
#z.SetDefaultColor(Color.white);
#z.setlineweight(4);
addchartbubble( bub, orl, wt, color.cyan, no);

#

IkqWg3c.jpg
 

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

not sure if i put the bubbles in the desired place. i don't see any boxes, just lines.
bubbles will be always shown. i didn't add code to turn them off.
i looked for a change in value of the lower cloud line, and placed a bubble there.

i don't know what WT is, i didn't verify the data. i just placed the data in a bubble.
have to have ext hours on to see this

Ruby:
# rangebox_01

# turn on ext hours

# inputs
input orStartTime = 1700;
input orEndTime = 0100;
input period = AggregationPeriod.FOUR_HOURS;
input showOnlyToday = no;
input showOnlyToday_boxes = yes;
input showCloud = yes;
input showboxes = yes;
input showMidpoint = yes;
input useAlerts = yes;
input useTradeSignals = no;
input day_of_week = {default Sunday};
# constants
def na = Double.NaN;
def hi = high(period = period);
def lo = low(period = period);
DefineGlobalColor("Cloud", Color.GRAY);

# opening range time logic
def overnight = orStartTime > orEndTime;
def pastORstart = SecondsFromTime(orStartTime) >= 0;
def beforeORend = SecondsTillTime(orEndTime) > 0;
def isOR =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
def isOR2 =
    (overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
#def isOr = SecondsTillTime(orEndTime) > 0 and SecondsFromTime(orStartTime) >= 0;
def today = (!showOnlyToday or GetDay() == GetLastDay()) and !IsNaN(close);
def today2 = (!showOnlyToday_boxes or GetDay() == GetLastDay()) and !IsNaN(close);
# opening range levels logic
def orhi =
    if orhi[1] == 0
        or !isOR[1]
        and isOR
    then hi
    else if isOR
        and hi > orhi[1]
    then hi
    else orhi[1];

def orlo =
    if orlo[1] == 0
        or !isOR[1]
        and isOR
    then lo
    else if isOR
        and lo < orlo[1]
    then lo
    else orlo[1];

# opening range levels logic
def orhi2 =
    if orhi2[1] == 0
        or !isOR2[1]
        and isOR2
    then hi
    else if isOR2
        and hi > orhi2[1]
    then hi
    else orhi2[1];

def orlo2 =
    if orlo2[1] == 0
        or !isOR2[1]
        and isOR2
    then lo
    else if isOR2
        and lo < orlo2[1]
    then lo
    else orlo2[1];
# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOR then (orh + orl) / 2 else na;

def orh2 = if today2 < 1 then na else orhi2;
def orl2 = if today2 < 1 then na else orlo2;

orm.SetHiding(!showMidpoint);


def range = orhi - orlo;

plot SHH25 = orh2 + .0025;
plot SHH50 = orh2 + .005;
plot SHL25 = orl2 - .0025;
plot SHL50 = orl2 - .005;
SHH25.Hide();
SHL25.Hide();
SHH50.Hide();
SHL50.Hide();
AddCloud(if showCloud and isOR then orh else na, if showCloud and isOR then orl else na, GlobalColor("cloud"), GlobalColor("cloud"));
AddCloud(if !showboxes then na else SHH50, SHH25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
AddCloud(if !showboxes then na else SHL50, SHL25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
# look and feel
orh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orm.SetPaintingStrategy(PaintingStrategy.DASHES);

orh.SetDefaultColor(Color.WHITE);
orl.SetDefaultColor(Color.WHITE);
orm.SetDefaultColor(Color.WHITE);

plot highBreak = useTradeSignals and !isOR and close crosses above orh;
plot highBreaklow = useTradeSignals and !isOR and close crosses below orh;
plot lowBreak = useTradeSignals and !isOR and close crosses below orl;
plot lowBreakhigh = useTradeSignals and !isOR and close crosses above orl;
plot midhighbreak = useTradeSignals and !isOR and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOR and close crosses below orm;
highBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
highBreaklow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreakhigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midhighbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midlowbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
highBreak.SetDefaultColor(Color.DARK_GREEN);
lowBreak.SetDefaultColor(Color.DARK_RED);
midhighbreak.SetDefaultColor(Color.DARK_GREEN);
midlowbreak.SetDefaultColor(Color.DARK_RED);
Alert(useAlerts and highBreak, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and highBreaklow, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreak, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreakhigh, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midhighbreak, "ORM Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midlowbreak, "ORM Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);


def wt = (orhi - orlo) * 10000;
AddLabel(close > 0, Concat( "WT: ", (orhi - orlo) * 10000), Color.CYAN);
#plot WT = if today == (orhi - orlo) then orlo - (3 * TickSize()) else Double.NaN;
#AddChartBubble(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);

def bub = if (orl[1] <> orl) then 1 else 0;
#plot z = if bub then orl else na;
#z.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
#z.SetDefaultColor(Color.white);
#z.setlineweight(4);
addchartbubble( bub, orl, wt, color.cyan, no);

#

IkqWg3c.jpg
It's used to measure the Asian consolidation period. if you put it on any of the future currency contracts, you'll see.
Try it on /6b or /6e. How would I get rid of the first bubble?
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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