RTH High and lows

Sagar

Member
Does anyone know how to plot RTH Highs, Lows and Mid for ES, NQ futures?? So high and lows and mid should be calculated after market open 9:30 AM EST till Close of market at 4:00 PM EST.

Below code is closest but it's not calculating correct values for Futures..
AutoFib

Click above link and click on expand to see the code. Appreciate your help.

Here is the code ... its picking Globex highs and lows too. I would need the values only for RTH open to close.

Code:
input display_rthrs_only = yes;

input ShowTodayOnly      = { default "No", "Yes"};
def s                    = ShowTodayOnly;
input period             = {default "Day", "Week", "Month"};
def closeByPeriod        = close(period = period)[-1];
def rthrs = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0;


input Fpos236 = .236;
input Fpos382 = .382;
input Fpos50  = .5;
input Fpos618 = .618;
input Fpos786 = .786;

def rhi =  if display_rthrs_only then if !rthrs then Double.NaN else high(period = period) else high(period = period);
def rlo =  if display_rthrs_only then if !rthrs then Double.NaN else low(period = period) else low(period = period);

def range  = rhi - rlo;
def F236   = rhi - (range * Fpos236);
def F382   = rhi - (range * Fpos382);
def F50    = rhi - (range * Fpos50);
def F618   = rhi - (range * Fpos618);
def F786   = rhi - (range * Fpos786);

plot ORH;
plot ORL;
plot Fib50;
plot Fib236;
plot Fib382;
plot Fib618;
plot Fib786;
if ShowTodayOnly and !IsNaN(closeByPeriod)
then {
    ORH      = Double.NaN;
    ORL      = Double.NaN;
    Fib50    = Double.NaN;
    Fib236   = Double.NaN;
    Fib382   = Double.NaN;
    Fib618   = Double.NaN;
    Fib786   = Double.NaN;

} else {
    ORH      = rhi;
    ORL      = rlo;
    Fib50    = F50;
    Fib236   = F236;
    Fib382   = F382;
    Fib618   = F618;
    Fib786   = F786;

}
;


ORH.SetDefaultColor(Color.GREEN);
ORH.SetStyle(Curve.LONG_DASH);
ORH.SetLineWeight(2);

ORL.SetDefaultColor(Color.RED);
ORL.SetStyle(Curve.LONG_DASH);
ORL.SetLineWeight(2);

Fib50.SetDefaultColor(Color.WHITE);
Fib50.SetStyle(Curve.LONG_DASH);
Fib50.SetLineWeight(1);

Fib236.SetDefaultColor(Color.CYAN);
Fib236.SetStyle(Curve.LONG_DASH);
Fib236.SetLineWeight(1);

Fib382.SetDefaultColor(Color.MAGENTA);
Fib382.SetStyle(Curve.LONG_DASH);
Fib382.SetLineWeight(1);

Fib618.SetDefaultColor(Color.YELLOW);
Fib618.SetStyle(Curve.LONG_DASH);
Fib618.SetLineWeight(1);

Fib786.SetDefaultColor(Color.DARK_RED);
Fib786.SetStyle(Curve.LONG_DASH);
Fib786.SetLineWeight(2);

input showbubbles = yes;

input bubblemover = 5;
def m = bubblemover;
def m1 = m + 1;
AddChartBubble(showbubbles and IsNaN(ORH[m]) and !IsNaN(ORH[m1]), ORH[m1], "H", ORH.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(ORL[m]) and !IsNaN(ORL[m1]), ORL[m1], "L", ORL.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib50[m]) and !IsNaN(Fib50[m1]), Fib50[m1], "50", Fib50.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib236[m]) and !IsNaN(Fib236[m1]), Fib236[m1], "236", Fib236.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib382[m]) and !IsNaN(Fib382[m1]), Fib382[m1], "382", Fib382.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib618[m]) and !IsNaN(Fib618[m1]), Fib618[m1], "618", Fib618.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib786[m]) and !IsNaN(Fib786[m1]), Fib786[m1], "786", Fib786.TakeValueColor());
 

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

Does anyone know how to plot RTH Highs, Lows and Mid for ES, NQ futures?? So high and lows and mid should be calculated after market open 9:30 AM EST till Close of market at 4:00 PM EST.

Below code is closest but it's not calculating correct values for Futures..
AutoFib

Click above link and click on expand to see the code. Appreciate your help.

Here is the code ... its picking Globex highs and lows too. I would need the values only for RTH open to close.

Code:
input display_rthrs_only = yes;

input ShowTodayOnly      = { default "No", "Yes"};
def s                    = ShowTodayOnly;
input period             = {default "Day", "Week", "Month"};
def closeByPeriod        = close(period = period)[-1];
def rthrs = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0;


input Fpos236 = .236;
input Fpos382 = .382;
input Fpos50  = .5;
input Fpos618 = .618;
input Fpos786 = .786;

def rhi =  if display_rthrs_only then if !rthrs then Double.NaN else high(period = period) else high(period = period);
def rlo =  if display_rthrs_only then if !rthrs then Double.NaN else low(period = period) else low(period = period);

def range  = rhi - rlo;
def F236   = rhi - (range * Fpos236);
def F382   = rhi - (range * Fpos382);
def F50    = rhi - (range * Fpos50);
def F618   = rhi - (range * Fpos618);
def F786   = rhi - (range * Fpos786);

plot ORH;
plot ORL;
plot Fib50;
plot Fib236;
plot Fib382;
plot Fib618;
plot Fib786;
if ShowTodayOnly and !IsNaN(closeByPeriod)
then {
    ORH      = Double.NaN;
    ORL      = Double.NaN;
    Fib50    = Double.NaN;
    Fib236   = Double.NaN;
    Fib382   = Double.NaN;
    Fib618   = Double.NaN;
    Fib786   = Double.NaN;

} else {
    ORH      = rhi;
    ORL      = rlo;
    Fib50    = F50;
    Fib236   = F236;
    Fib382   = F382;
    Fib618   = F618;
    Fib786   = F786;

}
;


ORH.SetDefaultColor(Color.GREEN);
ORH.SetStyle(Curve.LONG_DASH);
ORH.SetLineWeight(2);

ORL.SetDefaultColor(Color.RED);
ORL.SetStyle(Curve.LONG_DASH);
ORL.SetLineWeight(2);

Fib50.SetDefaultColor(Color.WHITE);
Fib50.SetStyle(Curve.LONG_DASH);
Fib50.SetLineWeight(1);

Fib236.SetDefaultColor(Color.CYAN);
Fib236.SetStyle(Curve.LONG_DASH);
Fib236.SetLineWeight(1);

Fib382.SetDefaultColor(Color.MAGENTA);
Fib382.SetStyle(Curve.LONG_DASH);
Fib382.SetLineWeight(1);

Fib618.SetDefaultColor(Color.YELLOW);
Fib618.SetStyle(Curve.LONG_DASH);
Fib618.SetLineWeight(1);

Fib786.SetDefaultColor(Color.DARK_RED);
Fib786.SetStyle(Curve.LONG_DASH);
Fib786.SetLineWeight(2);

input showbubbles = yes;

input bubblemover = 5;
def m = bubblemover;
def m1 = m + 1;
AddChartBubble(showbubbles and IsNaN(ORH[m]) and !IsNaN(ORH[m1]), ORH[m1], "H", ORH.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(ORL[m]) and !IsNaN(ORL[m1]), ORL[m1], "L", ORL.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib50[m]) and !IsNaN(Fib50[m1]), Fib50[m1], "50", Fib50.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib236[m]) and !IsNaN(Fib236[m1]), Fib236[m1], "236", Fib236.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib382[m]) and !IsNaN(Fib382[m1]), Fib382[m1], "382", Fib382.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib618[m]) and !IsNaN(Fib618[m1]), Fib618[m1], "618", Fib618.TakeValueColor());
AddChartBubble(showbubbles and IsNaN(Fib786[m]) and !IsNaN(Fib786[m1]), Fib786[m1], "786", Fib786.TakeValueColor());
Try replacing the top portion of your code with this to calculate the day's high/low. I added some labels as well for troubleshooting:

Ruby:
Input ShowCandleHighLabel = yes;
Input ShowCandleLowLabel = yes;
input aggregationPeriod = AggregationPeriod.DAY;
def currentDailyHigh = high(period = aggregationPeriod);
def currentDailyLow = low(period = aggregationPeriod);
DefineGlobalColor("PCH_Label", Color.LIGHT_GREEN);
DefineGlobalColor("PCL_Label", Color.PINK);
AddLabel(ShowCandleLowLabel, Concat ("DL: ", Round(currentDailyLow, 0)), GlobalColor("PCL_Label"));
AddLabel(ShowCandleHighLabel, Concat ("DH: ", Round(currentDailyHigh, 0)), GlobalColor("PCH_Label"));

input plotLines = yes;
def Today = GetLastDay() == GetDay();
plot ydayHigh = if Today and plotLines then currentDailyHigh else Double.NaN;
ydayHigh.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
ydayHigh.setDefaultColor(GlobalColor("PCH_Label"));

plot ydayLow = if Today and plotLines then currentDailyLow else Double.NaN;
ydayLow.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
ydayLow.setDefaultColor(GlobalColor("PCL_Label"));
 
Thread starter Similar threads Forum Replies Date
E calculate rth range and the average of the ranges over n days Index Futures 2

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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