Good afternoon,
I'm using the script below to show price range of a specific period as a label and a high price label during that period. I'd like to be able to convert this to a script so I can specify the period value in the interface, instead of having to create a new script for each value. So If I wanted to use a 60 day range, all I would need to do is type in 60 in the interface. Hope I was able to explain.
Here's the existing script I use:
I'm using the script below to show price range of a specific period as a label and a high price label during that period. I'd like to be able to convert this to a script so I can specify the period value in the interface, instead of having to create a new script for each value. So If I wanted to use a 60 day range, all I would need to do is type in 60 in the interface. Hope I was able to explain.
Here's the existing script I use:
Code:
def hi14 = Highest(high(period = AggregationPeriod.Day),14);
def low14 = Lowest(low(period = AggregationPeriod.Day),14);
def LastBar = HighestAll(if !IsNaN(close) then BarNumber() else Double.NaN);
def LastHigh = HighestAll(if BarNumber() == LastBar then Highest(high(period = AggregationPeriod.Day),14) else Double.NaN);
def Day; def Month; def Year;
if High == LastHigh{
Day = GetDayOfMonth(getyYYYMMDD());
Month = getmonth();
Year = getYear();
} else {
Day = Day[1];
Month = Month[1];
Year = Year[1];
}
addlabel(1, " 14 Day Range : $" + Round(low14, 2) + " to : $" + Round(hi14, 2) +" ", color.YELLOW);
Addlabel(yes, "High"+" on " + month + "/" + day + "/" + asprice(year)+" ",color.YELLOW);
#spacer
input Spacer = yes;
#spacer label
addlabel(Spacer, " ", color.BLACK);