Trouble Plotting Standard Deviation from Different Time Frame


New member
Still learning here it seems.

I have the standard deviation code, I just want to plot the middle regression line off the 4H chart on another Time Frame.

It's still drawing the line of the time frame I am currently in.

Can someone point out where I went astray?

Eventually I gong to input other deviations and time frames but need to get this one first. I took out the other inputs to try and simplify the code.

input length = 21;
input agg = aggregationPeriod.FOUR_HOURS;

def price = close(period = agg);

def regression;
def stdDeviation;
if (fullRange) {
    regression = InertiaAll(price);
    stdDeviation = stdevAll(price);
} else {
    regression = InertiaAll(price, length);
    stdDeviation = stdevAll(price, length);

plot MiddleLine = regression;

Similar threads