LinearRegChVar with Dynamic Cloud and Label For ThinkOrSwim

Carl-not-Karl

ToS Expert
VIP
<edited>

1) Included transparency ability under Globals tab in Edit Studies and Strategies dialog.
2) Included line code "# replace... " for user to change code to half-Cloud instead of full-Cloud.

I added a dynamic Cloud and Label (Up = GREEN / Down = RED) to the LinearRegChVar study found here:

https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/LinearRegChVar

1751642338204.png


Code:
input Cloud          = no;
input price          = close;
input widthOfChannel = 100.0;
input fullRange      = Yes;
input Label          = 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;

MiddleLR.DefineColor("Up", GetColor(6));
MiddleLR.DefineColor("Down", GetColor(5));
MiddleLR.AssignValueColor(if MiddleLR > MiddleLR[1] then MiddleLR.Color("Up") else MiddleLR.Color("Down"));
MiddleLR.SetLineWeight(1);
MiddleLR.SetStyle(1);
MiddleLR.HideBubble();
MiddleLR.HideTitle();

UpperLR.DefineColor("Up", GetColor(6));
UpperLR.DefineColor("Down", GetColor(5));
UpperLR.AssignValueColor(if UpperLR > UpperLR[1] then UpperLR.Color("Up") else UpperLR.Color("Down"));
UpperLR.SetLineWeight(1);
UpperLR.SetStyle(1);
UpperLR.HideBubble();
UpperLR.HideTitle();

LowerLR.DefineColor("Up", GetColor(6));
LowerLR.DefineColor("Down", GetColor(5));
LowerLR.AssignValueColor(if LowerLR > LowerLR[1] then LowerLR.Color("Up") else LowerLR.Color("Down"));
LowerLR.SetLineWeight(1);
LowerLR.SetStyle(1);
LowerLR.HideBubble();
LowerLR.HideTitle();

DefineGlobalColor("UpperLR", GetColor(6));
AddCloud(if Cloud and  MiddleLR > MiddleLR[1] then LowerLR else double.NaN, UpperLR,
 GlobalColor("UpperLR"), GlobalColor("UpperLR")); # replace LowerLR with MiddleLR for shading upper half
DefineGlobalColor("LowerLR", GetColor(5));
AddCloud(if Cloud and  MiddleLR < MiddleLR[1] then UpperLR else double.NaN, LowerLR,
  GlobalColor("LowerLR"), GlobalColor("LowerLR")); # replace UpperLR with MiddleLR for shading lower half

AddLabel(Label,
 if MiddleLR > MiddleLR[1] then
 " Bullish                                                                                           "
 else
 "                                                                                         Bearish ",
 if MiddleLR > MiddleLR[1] then Color.GREEN else Color.RED);
 
Last edited:
which time frame is woking for this study very well ?
i tested it in many timeframes and it show a bullish signals in highers frames even if the chart is already touched the upper linear
so i wanna know which timeframe is the best for this study
 
which time frame is woking for this study very well ?
i tested it in many timeframes and it show a bullish signals in highers frames even if the chart is already touched the upper linear
so i wanna know which timeframe is the best for this study
This default tos study (with my added cloud) works on all timeframes and is dependent on the length setting (how much time back: min., hrs., days, etc.): shorter the length the faster the study tips up or down.
It shows what has happened in the past (the trend) and is not predictive.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
247 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top