I'm trying to plot horizontal lines for the high and low for a date range that extends with user input. The code I've messing around with is below.
Ruby:
input startdate = 20210719;
input enddate = 20210820;
def ActivePeriod = if DaysFromDate(startdate) >= 0 and DaysTillDate(enddate) >= 0 then yes else Double.NaN;
def vbegin = GetYYYYMMDD() == startdate;
def vend = GetYYYYMMDD() == enddate;
AddVerticalLine(vbegin, "Range Starts", Color.GREEN, Curve.FIRM);
AddVerticalLine(vend, "Range Ends", Color.GREEN, Curve.FIRM);
plot Test = if vbegin then Highest(high) else Double.NaN;
Test.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Test.SetDefaultColor(Color.YELLOW);
plot Test1 = if vbegin then lowest(low) else Double.NaN;
Test1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Test1.SetDefaultColor(Color.YELLOW);
Last edited: