Yesterday High & Low RTH


Category:
0
0

Hi guys, I am trying to find a study on ToS that plots yesterday’s high and low but only during RTH. I have found a few studies that get pretty close but they are missing one thing or another, (some of them only chart the high and low levels on that day, not on the current trading day). This study is the best I have but it includes extended or overnight trading hours. Does anyone how I can get yesterday’s high and low levels for Regular Trading Hours only? Thanks

I got this code from another user. Username: True, from another site.

#hint:<b>Plots the high, low and close and open of inputted days ago</b>\n The plots persist across to the right of the chart.\n Bubbles identify the plots.\nWorks for all aggregations thru ‘Day’.

declare upper;
declare hide_on_daily;
input DaysAgo = 1;#hint DaysAgo: Excludes today
input PlotHigh = yes;
input PlotLow = yes;
input PlotClose = yes;
input PlotOpen = no;
input ShowBubbles = yes;

def AdjDaysAgo = DaysAgo + 1; #Adjusted to match a true LastDate which includes today

def day = GetDay();
def lastDay = GetLastDay();
def year = GetYear();
def lastYear = GetLastYear();
def yyyymmdd = GetYYYYMMDD();
def lastDate = HighestAll( if day == lastDay and year == lastYear then yyyymmdd else Double.NaN );
def currentDate = if yyyymmdd < lastDate then yyyymmdd else lastDate;
def tradingDaysAgo = CountTradingDays( currentDate, lastDate );
def previousDayPlus = tradingDaysAgo <= AdjDaysAgo;
def today = lastDate == currentDate;

script previousPlot {
input today = no;
input previousDayPlus = no;
input data = high;

plot previousPlot = if previousDayPlus then
HighestAll(if today then data else Double.NaN)
else Double.NaN;
}

plot previousHigh = previousPlot(today, PlotHigh and previousDayPlus, high( period = “DAY” )[DaysAgo]);
plot PreviousLow = previousPlot(today, PlotLow and previousDayPlus, low( period = “DAY” )[DaysAgo]);
plot PreviousClose = previousPlot(today, PlotClose and previousDayPlus, close( period = “DAY” )[DaysAgo]);
plot PreviousOpen = previousPlot(today, PlotOpen and previousDayPlus, open( period = “DAY” )[DaysAgo]);

#=========== Chart Bubbles ===================
def FirstBar = ShowBubbles and today != today[1];
AddChartBubble(FirstBar, previousHigh, (“High of ” + DaysAgo + ” day(s) ago”), color = previousHigh.TakeValueColor());
AddChartBubble(FirstBar, PreviousLow, (“Low of ” + DaysAgo + ” day(s) ago”), color = PreviousLow.TakeValueColor());
AddChartBubble(FirstBar, PreviousClose, (“Close of ” + DaysAgo + ” day(s) ago”), color = PreviousClose.TakeValueColor());
AddChartBubble(FirstBar, PreviousOpen, (“Open of ” + DaysAgo + ” day(s) ago”), color = PreviousOpen.TakeValueColor());

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on April 16, 2019 9:31 am
1396 views
1
Private answer

Here’s one I built and use. It also has an alert when this crosses. If sharing a link like this isn’t allowed, I do apologize and will gladly share the code. http://tos.mx/eh5eGq

Marked as spam
Posted by (Questions: 21, Answers: 47)
Answered on April 16, 2019 8:50 pm
0

Wow. This is perfect. Thank you so much!

( at April 17, 2019 6:40 am)
0
Hi Ryan, It seems like the indicator does not plot the High correctly. I’m looking at yesterday high for YM (4/22), and the High was 26629, but indicator showing 26550. Please look into it and fix. Thank you!
( at April 23, 2019 6:24 am)
0

You can adjust the time for futures. May not be picking up globex trading.

( at April 24, 2019 3:20 pm)
0
Private answer

The only issue I have with these links is that they expire after several months. Please post the full code when you get a chance. Thanks for providing a solution to your request.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 16, 2019 9:01 pm