Covert clouds on Linear Reg Channel to lines


Category:
0
0

Hi Pete!  I am working with an indicator in TOS that plots a linear regression channel. (photo attached + code below). I am trying to edit this script so that instead of printing a cloud, TOS instead prints a center line, a line at the top deviation, and a line at  the top deviation.   The cloud is obscuring other indicators that I am using so I’m hoping to replace it with just lines instead. Thanks for any tips!

input price = close;
input deviations = 1.0; #set your deviation units here.
input length = 80; #set your channel lookback period here.

def regression = InertiaAll(price, length);
def stdDeviation = StDevAll(price, length);
def UpCloud = regression + deviations * stdDeviation;
def DnCloud = regression – deviations * stdDeviation;
def MiddleLine = regression;

DefineGlobalColor(“Bullish”, Color.light_green);
DefineGlobalColor(“Bearish”, Color.light_RED);

AddCloud(middleline, upcloud, GlobalColor(“Bullish”), GlobalColor(“Bullish”));
AddCloud(middleline, dncloud, GlobalColor(“Bearish”), GlobalColor(“Bearish”));

Attachments:
Marked as spam
Posted by (Questions: 7, Answers: 1)
Asked on June 14, 2022 10:33 am
92 views
0
Private answer

The simplest solution is to just use the built-in linear regression study included with Thinkorswim. The name of the study is "LinearRegChVar". Screenshot below shows the settings you will apply to match the default values in the code you provided with your question.

But if you really wanted to do this the hard way. Simply remove the last four lines of your code and change the last three lines which remain from "def" to "plot" statements.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on June 14, 2022 11:16 am