Hi, I am new here.
I am working on Thinkscript to display linear regression channel from a (5D1h) timeframe in a 5min chart.
I tried to to alter the aggreation period like below, however, the Linear Regression Channel's value plotted on 5min (in same interval of 5Days) chart is not the same as the 5D1h chart. Could anyone shed some light? Thanks!
input aggregationPeriod = AggregationPeriod.HOUR;
def price = close(period = aggregationPeriod);
plot MiddleLR = InertiaAll(price);
def dist = HighestAll(AbsValue(MiddleLR - price));
plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
MiddleLR.setDefaultColor(GetColor(5));
UpperLR.setDefaultColor(GetColor(5));
LowerLR.setDefaultColor(GetColor(5));
plot MiddleLR2 = InertiaAll(price);
def dist2 = HighestAll(AbsValue(MiddleLR2 - price)) * 0.5;
plot UpperLR2 = MiddleLR2 + dist2;
plot LowerLR2 = MiddleLR2 - dist2;
MiddleLR2.setDefaultColor(GetColor(1));
UpperLR2.setDefaultColor(GetColor(1));
LowerLR2.setDefaultColor(GetColor(1));
I am working on Thinkscript to display linear regression channel from a (5D1h) timeframe in a 5min chart.
I tried to to alter the aggreation period like below, however, the Linear Regression Channel's value plotted on 5min (in same interval of 5Days) chart is not the same as the 5D1h chart. Could anyone shed some light? Thanks!
input aggregationPeriod = AggregationPeriod.HOUR;
def price = close(period = aggregationPeriod);
plot MiddleLR = InertiaAll(price);
def dist = HighestAll(AbsValue(MiddleLR - price));
plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
MiddleLR.setDefaultColor(GetColor(5));
UpperLR.setDefaultColor(GetColor(5));
LowerLR.setDefaultColor(GetColor(5));
plot MiddleLR2 = InertiaAll(price);
def dist2 = HighestAll(AbsValue(MiddleLR2 - price)) * 0.5;
plot UpperLR2 = MiddleLR2 + dist2;
plot LowerLR2 = MiddleLR2 - dist2;
MiddleLR2.setDefaultColor(GetColor(1));
UpperLR2.setDefaultColor(GetColor(1));
LowerLR2.setDefaultColor(GetColor(1));