Lowest Low and Highest High between 2 dates


Category:
0
0

Hi Pete

Any chance to create this chart study to Draw a horizontal ray with its respective value for Lowest Low and Highest High between 2 Dates

Thanks

Marked as spam
Posted by (Questions: 12, Answers: 1)
Asked on November 5, 2020 10:26 am
315 views
0
Private answer

Yes, however this is only going to work on a daily time frame or higher. Why? Because in order to use a specific "date" you cannot apply this to an intraday time frame. For that you would need to include a time component as well. And trying to get that to work is a real chore.

Here is the code as you requested. I have added to vertical lines that show up on the chart so you can see the start and end dates selected through user inputs. The date you enter for each input should be a date the markets were open. Otherwise you may end up with unexpected results.

input startDate = 20200901;
input endDate = 20201030;
def targetPeriod = DaysFromDate(startDate) >= 0 and DaysTillDate(endDate) >= 0;
rec trackHighestHigh = if targetPeriod and !targetPeriod[1] then high else if targetPeriod and high > trackHighestHigh[1] then high else trackHighestHigh[1];
rec trackLowestLow = if targetPeriod and !targetPeriod[1] then low else if targetPeriod and low > 0 and low < trackLowestLow[1] then low else trackLowestLow[1];
plot higehstInPeriod = trackHighestHigh;
plot lowestInPeriod = trackLowestLow;
AddVerticalLine(targetPeriod and !targetPeriod[1], "Period Start");
AddVerticalLine(targetPeriod and !targetPeriod[-1], "Period End");

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 5, 2020 1:03 pm