I'm trying to create a linear regression MTF but have a problem with plotting the upper and lower lines. Any help would be greatly appreciate.
def fourHours = close(period = AggregationPeriod.FOUR_HOURS); def day = close(period = AggregationPeriod.DAY); def week = close(period = AggregationPeriod.WEEK); def month = close(period = AggregationPeriod.MONTH); def period=yes; plot data=close; input price = close; input deviations = .8; input length = 200; #set your channel lookback period here. input opacity = 50; def regression = InertiaAll(price, length); def stdDeviation = StDevAll(price, length); plot UpperLine = regression + deviations * stdDeviation; plot LowerLine = regression - deviations * stdDeviation; def dayreg=InertiaAll(price-day,length); def daysd= StDevAll(price-day,length); plot dayupper=dayreg+deviations*daysd;
Last edited by a moderator: