You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter JonPM
- Start date

http://tos.mx/N6lW6NE

@diazlaz @Ficus I wanted to have an LRC that was opaque. This was done w help from TOS Support.

Code:

```
# LRC no Lines Global Color Adj
# With help from coder in TOS chat support 9-18-2020
# Originally: tradingview like Linear Channel w/ fills
# @JonPM Community Request in useThinkscript
# VERSION
# 2020.09.08 V1.0 @diazlaz - Linear Regression Channel with Cloud and variable
# timeframe.
# 2020.09.18 V1.1 @markos - Color Opacity can now be changed via Globals in UI.
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"));
# End LRC wo Lines
```

Hi @JonPM,

here you go:

here you go:

Ruby:

```
#tradingview like Linear Channel w/ fills
#@JonPM Community Request
#
#VERSION
# 2020.09.08 V1.0 @diazlaz - Linear Regression Channel with Cloud and variable
# timeframe.
#
input price = close;
input deviations = .8; #set your deviation units here.
input length = 100; #set your channel lookback period here.
def regression = InertiaAll(price, length);
def stdDeviation = stdevAll(price, length);
plot UpperLine = regression + deviations * stdDeviation;
plot MiddleLine = regression;
plot LowerLine = regression - deviations * stdDeviation;
AddCloud (MiddleLine, UpperLine, COLOR.GREEN, COLOR.GREEN);
AddCloud (MiddleLine, LowerLine, COLOR.RED, COLOR.RED);
UpperLine.SetDefaultColor(COLOR.GREEN);
MiddleLine.SetDefaultColor(GetColor(8));
LowerLine.SetDefaultColor(COLOR.RED);
#END of tradingview like Linear Channel w/ fills
```

Last edited by a moderator:

Code:

```
#tradingview like Linear Channel w/ fills
#@JonPM Community Request
#
#VERSION
# 2020.09.08 V1.0 @diazlaz - Linear Regression Channel with Cloud and variable
# timeframe.
#
input price = close;
input deviations = .8; #set your deviation units here.
input length = 100; #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 MiddleLine = regression;
plot LowerLine = regression - deviations * stdDeviation;
AddCloud(MiddleLine, UpperLine, Color.GREEN, Color.GREEN, opacity);
AddCloud(MiddleLine, LowerLine, Color.RED, Color.RED, opacity);
UpperLine.SetDefaultColor(Color.GREEN);
MiddleLine.SetDefaultColor(GetColor(8));
LowerLine.SetDefaultColor(Color.RED);
#END of tradingview like Linear Channel w/ fills
```

http://tos.mx/N6lW6NE

@diazlaz @Ficus I wanted to have an LRC that was opaque. This was done w help from TOS Support.

Code:

```
# LRC no Lines Global Color Adj
# With help from coder in TOS chat support 9-18-2020
# Originally: tradingview like Linear Channel w/ fills
# @JonPM Community Request in useThinkscript
# VERSION
# 2020.09.08 V1.0 @diazlaz - Linear Regression Channel with Cloud and variable
# timeframe.
# 2020.09.18 V1.1 @markos - Color Opacity can now be changed via Globals in UI.
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"));
# End LRC wo Lines
```

Last edited:

You don't really trade based on this alone. The green and red zones give you an idea of possible support and resistance as well as the overall trend direction. Just notice how the price seems to bump up and down near the top, bottom and middle.How do you guys trade using this?

phewww you got your work cut out for you. What exactly are you going to use that for? Just curious

well, if the mid line cuts through most of the candle bodies, it means the trend is uniform and when there is pullback, i want to get in.phewww you got your work cut out for you. What exactly are you going to use that for? Just curious

oook, have at it.well, if the mid line cuts through most of the candle bodies, it means the trend is uniform and when there is pullback, i want to get in.

I know you put in the request a LONG time ago, but I had a thought.

you can create a series:

Code:

`def pierced_bars = if open > MiddleLine and close < MiddleLine then 1 else 0;`

Code:

`addLabel(yes, "Pierced Bars Last 80: " + sum(pierced_bars, 80), color.gray);`

You could also chart it on a lower study and see how it changes over time. I don't know if it will repaint, or give the number of bars that CURRENTLY fit the condition but I assume so (it will be recalculated at each new bar). If you need the historical values, it gets much, much messier.

Hope this is still of some help.

-mashume

P.S. I've coded all this in the post-editor, not in ToS, it may not run quite right right off, but it should be close.

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

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

W | Scan for Close < Linear Regression Indicator | Questions | 1 | |

M | Create AddOrder statement for Linear Regression Slope | Questions | 1 | |

R | Linear Regression Reversal Scan | Questions | 0 | |

Linear Regression R-Squared | Questions | 1 | ||

G | Linear regression for rsi and slow stochastic | Questions | 1 |

Start a new thread and receive assistance from our community.

87k+
Posts

369
Online

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

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.

- The most viewed thread:

https://usethinkscript.com/threads/repainting-trend-reversal-for-thinkorswim.183/ - Our most popular indicator:

https://usethinkscript.com/threads/buy-the-dip-indicator-for-thinkorswim.3553/ - Answers to frequently asked questions:

https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/

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.