Linear regression channel range label


0
0

Hey Pete,

I’ve seen a few labels being created but was wondering if you could create a label showing the range of a linear regression channel from upper LR to lower LR.

here is the code for the linear regression channel I’m using.

input price = close;
input widthOfChannel = 100.0;
input fullRange = Yes;
input length = 21;

plot MiddleLR;
if (fullRange)
then {
MiddleLR = InertiaAll(price);
} else {
MiddleLR = InertiaAll(price, length);
}

def dist = HighestAll(AbsValue(MiddleLR – price)) * (widthOfChannel / 100.0);

plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR – dist;
plot UpperLRm1 = MiddleLR + dist * (-.525);
plot UpperLRm2 = MiddleLR + dist * .573;
plot lowerLRm1 = MiddleLR – dist * .577;
plot LowerLRm2 = MiddleLR – dist * (-.525);

MiddleLR.SetDefaultColor(GetColor(5));
UpperLR.SetDefaultColor(GetColor(5));
LowerLR.SetDefaultColor(GetColor(5));;
AddCloud(upperLR, middleLR, Color.GREEN, Color.GRAY);
AddCloud(middleLR, lowerLR, Color.RED, Color.GRAY);

Marked as spam
Posted by (Questions: 4, Answers: 7)
Asked on October 16, 2019 5:17 am
22 views
0
Private answer

Add this to the bottom of your code:

AddLabel(yes, Concat("LRC Range: ", UpperLR -LowerLR), Color.WHITE);

Full details about adding chart labels can be found here:

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel.html

Marked as spam
Posted by (Questions: 36, Answers: 2222)
Answered on October 16, 2019 9:05 am
That's awesome Pete. I just didn't get that coding gene, at some level its disappointing but I didn't get the carpentry gene from my dad either and he wasn't a great teacher. The best part about your answer was the link to ToS on how to create labels. thanks for that.
( at October 16, 2019 11:09 am)