# high and low for specific time?

0
0

Hi Pete,

I tried searching for this but I didn’t have any luck.

I want to plot the high and low for a specific time period, 15:00 to 16:15 for example, but I also want the line to only plot during that time period if possible. I’ll show you what I tried, but it’s not correct.

def fifteen = if SecondsFromTime(1500) >= 0 and SecondsTillTime(1615) >= 0 then 1 else 0;

def Hourlyhigh = high(period = AggregationPeriod.hour);
def HourlyLow = low(period = AggregationPeriod.hour);

plot fifteenHigh = if fifteen then HourlyHigh else Double.NaN;
plot fifteenLow = if fifteen then HourlyLow else Double.NaN;

Thank you!

Marked as spam Posted by (Questions: 2, Answers: 4)
Asked on October 15, 2019 4:06 pm
73 views
 ▲ 0 ▼ ✔ Private answer The solution to this requires the use of recursive variables. This code makes use of very advanced techniques. ```input startTime = 1500; input endTime = 1615; def targetPeriod = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0; rec targetPeriodHigh = if targetPeriod and !targetPeriod then high else if high > targetPeriodHigh and targetPeriod then high else targetPeriodHigh; rec targetPeriodLow = if targetPeriod and !targetPeriod then low else if low > 0 and low < targetPeriodLow and targetPeriod then low else targetPeriodLow; def okToPlot = GetDay() == GetLastDay() and targetPeriod; plot targetHigh = if okToPlot then HighestAll(if okToPlot then targetPeriodHigh else Double.NaN) else Double.NaN; plot targetLow = if okToPlot then LowestAll(if okToPlot then targetPeriodLow else Double.NaN) else Double.NaN;``` Marked as spam Posted by Pete Hahn (Questions: 37, Answers: 2830) Answered on October 15, 2019 4:36 pm Oh yeah, It's not likely that I would have figured that out. Thank you! Is it possible to make it plot the high and low for that time period on previous days as well? I tried making some adjustments, but again couldn't figure it out. Thank you! (Robert Totland at October 15, 2019 9:21 pm) There is no simple solution for that. The use of the HighestAll() and LowestAll() functions requires that we limit this to only display only on the current day's chart data. If this is absolutely critical you can submit a custom project request and pay for a more complex solution. (Pete Hahn at October 16, 2019 9:08 am) Hi again. Thank you. I've also used this method to get the high, low and mid from 9:30 to 16:15 but I can't seem to get the chartbubble to show up using this line that I usually use for bubbles. addChartBubble (IsNaN(close) and !IsNaN(close), themid, "RTH Mid", color.cyan,yes); Is there a different script to add a bubble to this or another way to plot the RTH High, low, and mid that will accept chartbubbles? Thanks again. (Robert Totland at October 18, 2019 9:57 pm)