Plot previous day high and low on intraday chart


Category:
0
0

Seeing if you could help me try to plot a previous high of day and low of day line to chart on the current day. So basically on my charts today 5/23, I would like a script to chart the high of day and low of day of 5/22.

I have a similar script that does the premarket high and low. Here is the script

Input startTime = 400;

input endTime = 929;

def timeUntilClose = SecondsTillTime(endTime);

def timeUntilOpen = SecondsTillTime(startTime);

def targetPeriod = timeUntilClose > 0;

rec targetPeriodHigh = if targetPeriod and !targetPeriod[1] then high else if targetPeriod and high > targetPeriodHigh[1] then high else targetPeriodHigh[1];

rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low else if targetPeriod and low < targetPeriodLow[1] and low > 0 then low else targetPeriodLow[1];

 

plot pmHigh = targetPeriodHigh;

plot pmLow = targetPeriodLow;

 

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on May 23, 2022 10:46 am
730 views
0
Private answer

This question has already been solved at least two times so far in this forum. I updated the title of your question to increase the chances this question will show up near the top of the search results.

You did not specify whether your previous day high and low should include or exclude extended hour session. So I will present the easier of those two solution.

plot previousDayHigh = high(period = AggregationPeriod.DAY)[1];
previousDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
previousDayHigh.SetDefaultColor(Color.GREEN);
plot previousDayLow = low(period = AggregationPeriod.DAY)[1];
previousDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
previousDayLow.SetDefaultColor(Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on May 23, 2022 2:38 pm
0
Thanks alot for your help.
( at May 23, 2022 2:54 pm)