Need help adjusting the below code so that when the chart has the right side on expansion, it only displays the previous week's levels (like pic #1)
As it currently works, when expansion is on (Pic #2). its plotting the current levels in addition to previous week.
I feel like this is an easy tweak but I'm totally stuck on how to fix it!
Hoping this makes sense. Thanks for the help
##boiler plate TOS script ##
input aggregationPeriod = AggregationPeriod.WEEK;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no
plot DailyHigh;
plot DailyLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DailyHigh = Double.NaN;
DailyLow = Double.NaN;
} else {
DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
#mid level ##
def PR = DailyHigh - DailyLow;
plot Week_Mid = DailyLow + (PR / 2);
As it currently works, when expansion is on (Pic #2). its plotting the current levels in addition to previous week.
I feel like this is an easy tweak but I'm totally stuck on how to fix it!
Hoping this makes sense. Thanks for the help
##boiler plate TOS script ##
input aggregationPeriod = AggregationPeriod.WEEK;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no
plot DailyHigh;
plot DailyLow;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
DailyHigh = Double.NaN;
DailyLow = Double.NaN;
} else {
DailyHigh = Highest(high(period = aggregationPeriod)[-displace], length);
DailyLow = Lowest(low(period = aggregationPeriod)[-displace], length);
}
#mid level ##
def PR = DailyHigh - DailyLow;
plot Week_Mid = DailyLow + (PR / 2);