Coral Trend Indicator For ThinkOrSwim

Code:
# https://www.tradingview.com/script/qyUwc2Al-Coral-Trend-Indicator-LazyBear/
# // @author LazyBear
# ToS Conversion: mashume

# study(title="Coral Trend Indicator [LazyBear]", shorttitle="CTI_LB", overlay=true)

declare upper;
def src = close;
input sm = 21;
input cd = 0.4;

script nz {
    input data = 0;
    def ret_val = if isNaN(data) then 0 else data;
    plot return = ret_val;
}

def di = (sm - 1.0) / 2.0 + 1.0;
def c1 = 2 / (di + 1.0);
def c2 = 1 - c1;
def c3 = 3.0 * (cd * cd + cd * cd * cd);
def c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
def c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;
def i1 = c1*src + c2*nz(i1[1]);
def i2 = c1*i1 + c2*nz(i2[1]);
def i3 = c1*i2 + c2*nz(i3[1]);
def i4 = c1*i3 + c2*nz(i4[1]);
def i5 = c1*i4 + c2*nz(i5[1]);
def i6 = c1*i5 + c2*nz(i6[1]);

def bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);
def temp = if !isNaN(bfr) then bfr else double.nan;
def bfrC = if bfr > nz(bfr[1]) then 1 else if bfr < nz(bfr[1]) then -1 else 0;
plot ribm = temp;
ribm.AssignValueColor(if bfrC == 1 then color.green else if bfrC == -1 then color.red else color.blue);
 
Code:
# https://www.tradingview.com/script/qyUwc2Al-Coral-Trend-Indicator-LazyBear/
# // @author LazyBear
# ToS Conversion: mashume

# study(title="Coral Trend Indicator [LazyBear]", shorttitle="CTI_LB", overlay=true)

declare upper;
def src = close;
input sm = 21;
input cd = 0.4;

script nz {
    input data = 0;
    def ret_val = if isNaN(data) then 0 else data;
    plot return = ret_val;
}

def di = (sm - 1.0) / 2.0 + 1.0;
def c1 = 2 / (di + 1.0);
def c2 = 1 - c1;
def c3 = 3.0 * (cd * cd + cd * cd * cd);
def c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
def c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;
def i1 = c1*src + c2*nz(i1[1]);
def i2 = c1*i1 + c2*nz(i2[1]);
def i3 = c1*i2 + c2*nz(i3[1]);
def i4 = c1*i3 + c2*nz(i4[1]);
def i5 = c1*i4 + c2*nz(i5[1]);
def i6 = c1*i5 + c2*nz(i6[1]);

def bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);
def temp = if !isNaN(bfr) then bfr else double.nan;
def bfrC = if bfr > nz(bfr[1]) then 1 else if bfr < nz(bfr[1]) then -1 else 0;
plot ribm = temp;
ribm.AssignValueColor(if bfrC == 1 then color.green else if bfrC == -1 then color.red else color.blue);
So great Job, appreciate for your talent
 
@mashume : Nicely done...Thank you...

I took the liberty of adding two additional lines to further complete the recreation of the indicator:
Code:
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);

The completed script is as follows:
Code:
# https://www.tradingview.com/script/qyUwc2Al-Coral-Trend-Indicator-LazyBear/
# // @author LazyBear
# ToS Conversion: mashume

# study(title="Coral Trend Indicator [LazyBear]", shorttitle="CTI_LB", overlay=true)

declare upper;
def src = close;
input sm = 21;
input cd = 0.4;

script nz {
    input data = 0;
    def ret_val = if isNaN(data) then 0 else data;
    plot return = ret_val;
}

def di = (sm - 1.0) / 2.0 + 1.0;
def c1 = 2 / (di + 1.0);
def c2 = 1 - c1;
def c3 = 3.0 * (cd * cd + cd * cd * cd);
def c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
def c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;
def i1 = c1*src + c2*nz(i1[1]);
def i2 = c1*i1 + c2*nz(i2[1]);
def i3 = c1*i2 + c2*nz(i3[1]);
def i4 = c1*i3 + c2*nz(i4[1]);
def i5 = c1*i4 + c2*nz(i5[1]);
def i6 = c1*i5 + c2*nz(i6[1]);

def bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);
def temp = if !isNaN(bfr) then bfr else double.nan;
def bfrC = if bfr > nz(bfr[1]) then 1 else if bfr < nz(bfr[1]) then -1 else 0;
plot ribm = temp;
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);
ribm.AssignValueColor(if bfrC == 1 then color.green else if bfrC == -1 then color.red else color.blue);

a.png


Good Luck and Good Trading :cool:
 
Last edited:
@mashume : Nicely done...Thank you...

I took the liberty of adding two additional lines to further complete the recreation of the indicator:
Code:
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);

The completed script is as follows:
Code:
# https://www.tradingview.com/script/qyUwc2Al-Coral-Trend-Indicator-LazyBear/
# // @author LazyBear
# ToS Conversion: mashume

# study(title="Coral Trend Indicator [LazyBear]", shorttitle="CTI_LB", overlay=true)

declare upper;
def src = close;
input sm = 21;
input cd = 0.4;

script nz {
    input data = 0;
    def ret_val = if isNaN(data) then 0 else data;
    plot return = ret_val;
}

def di = (sm - 1.0) / 2.0 + 1.0;
def c1 = 2 / (di + 1.0);
def c2 = 1 - c1;
def c3 = 3.0 * (cd * cd + cd * cd * cd);
def c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
def c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;
def i1 = c1*src + c2*nz(i1[1]);
def i2 = c1*i1 + c2*nz(i2[1]);
def i3 = c1*i2 + c2*nz(i3[1]);
def i4 = c1*i3 + c2*nz(i4[1]);
def i5 = c1*i4 + c2*nz(i5[1]);
def i6 = c1*i5 + c2*nz(i6[1]);

def bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);
def temp = if !isNaN(bfr) then bfr else double.nan;
def bfrC = if bfr > nz(bfr[1]) then 1 else if bfr < nz(bfr[1]) then -1 else 0;
plot ribm = temp;
ribm.setpaintingstrategy(paintingstrategy.points);
ribm.setlineweight(5);
ribm.AssignValueColor(if bfrC == 1 then color.green else if bfrC == -1 then color.red else color.blue);

Good Luck and Good Trading :cool:
Thanks for the superior jobs
 

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
535 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