TrendFlex Oscillator For ThinkOrSwim

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

Here is both TrendFlex and Reflex with the overbought and oversold lines added, the cloud, and visuals to match the tradingview versions you referenced.


TrendFlex:
Code:
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def average = filter - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Trendflex = average / rms;
plot ZeroLine = 0;
#Trendflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# TrendFlex additions by bigboss
input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then TrendFlex else Double.NaN,Color.PLUM,color.PLUM);

TrendFlex.SetDefaultColor(Color.MAGENTA);
ZeroLine.SetDefaultColor(Color.WHITE);

TrendFlex.SetLineWeight(lineThickness);

ob.SetDefaultColor(color.RED);
os.SetDefaultColor(color.GREEN);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);

Reflex:
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def slope = (filter[length] - filter) / length;
def average = filter + slope * (length + 1) / 2 - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Reflex = average / rms;
plot ZeroLine = 0;

#Reflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# Reflex additions by bigboss

input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then Reflex else Double.NaN,Color.YELLOW,Color.YELLOW);

ZeroLine.SetDefaultColor(Color.WHITE);
Reflex.SetDefaultColor(Color.YELLOW);

Reflex.SetLineWeight(2);

ob.SetDefaultColor(Color.RED);
os.SetDefaultColor(Color.GREEN);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
 
Here is both TrendFlex and Reflex with the overbought and oversold lines added, the cloud, and visuals to match the tradingview versions you referenced.


TrendFlex:
Code:
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def average = filter - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Trendflex = average / rms;
plot ZeroLine = 0;
#Trendflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# TrendFlex additions by bigboss
input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then TrendFlex else Double.NaN,Color.PLUM,color.PLUM);

TrendFlex.SetDefaultColor(Color.MAGENTA);
ZeroLine.SetDefaultColor(Color.WHITE);

TrendFlex.SetLineWeight(lineThickness);

ob.SetDefaultColor(color.RED);
os.SetDefaultColor(color.GREEN);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);

Reflex:
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def slope = (filter[length] - filter) / length;
def average = filter + slope * (length + 1) / 2 - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Reflex = average / rms;
plot ZeroLine = 0;

#Reflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# Reflex additions by bigboss

input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then Reflex else Double.NaN,Color.YELLOW,Color.YELLOW);

ZeroLine.SetDefaultColor(Color.WHITE);
Reflex.SetDefaultColor(Color.YELLOW);

Reflex.SetLineWeight(2);

ob.SetDefaultColor(Color.RED);
os.SetDefaultColor(Color.GREEN);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
I think TrendFlex has a better idea of the price movement than reflex thanks
 
Here is both TrendFlex and Reflex with the overbought and oversold lines added, the cloud, and visuals to match the tradingview versions you referenced.


TrendFlex:
Code:
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def average = filter - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Trendflex = average / rms;
plot ZeroLine = 0;
#Trendflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# TrendFlex additions by bigboss
input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then TrendFlex else Double.NaN,Color.PLUM,color.PLUM);

TrendFlex.SetDefaultColor(Color.MAGENTA);
ZeroLine.SetDefaultColor(Color.WHITE);

TrendFlex.SetLineWeight(lineThickness);

ob.SetDefaultColor(color.RED);
os.SetDefaultColor(color.GREEN);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);

Reflex:
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def slope = (filter[length] - filter) / length;
def average = filter + slope * (length + 1) / 2 - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Reflex = average / rms;
plot ZeroLine = 0;

#Reflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# Reflex additions by bigboss

input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then Reflex else Double.NaN,Color.YELLOW,Color.YELLOW);

ZeroLine.SetDefaultColor(Color.WHITE);
Reflex.SetDefaultColor(Color.YELLOW);

Reflex.SetLineWeight(2);

ob.SetDefaultColor(Color.RED);
os.SetDefaultColor(Color.GREEN);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
I have this other indicator from pine script but I got a couple of elements here that I don't find samples how to change to thinkscript online like the iff and ce, nz.

Code:
study("Adaptive Ergodic Candlestick Oscillator [LazyBear]", shorttitle="AECO_LB")
length=input(defval=14, title="Stoch Scaling Length"), sl=input(defval=9, title="Signal Length")
ep=input(defval=5, title="Smooth Length")
vrb= abs( stoch(close, high, low, length)-50)/50
mep=2/(ep+1), ce=cum(1)<=((length+ep)*2)
came1=iff(ce,close-open,nz(came1[1])+mep*vrb*((close-open)-nz(came1[1])))
came2=iff(ce,high-low,nz(came2[1])+mep*vrb*((high-low)-nz(came2[1])))
came11=iff(ce,came1,nz(came11[1])+mep*vrb*(came1-nz(came11[1])))
came22=iff(ce,came2,nz(came22[1])+mep*vrb*(came2-nz(came22[1])))
eco=came11/came22*100.0
se=ema(eco, sl)
ebc=input(false, title="Enable Bar colors")
bc_=eco>0 ? (eco>eco[1]?green:orange) : (eco<eco[1]?red:orange)
bc_t=eco>0 ? (eco>se?lime:orange) : (eco<se?red:orange)
bc=ebc? bc_t : na
barcolor(bc)
plot(0, title="MidLine")
plot(eco, style=histogram, color=bc_,linewidth=2, title="ECOHisto_1")
plot(eco, color=black, linewidth=2, title="AECO")

well I presume that iff its the if statement but I get loss because I don't see the then and else, maybe nz is a substitution for that inside those lines?
 
I have this other indicator from pine script but I got a couple of elements here that I don't find samples how to change to thinkscript online like the iff and ce, nz.

Code:
study("Adaptive Ergodic Candlestick Oscillator [LazyBear]", shorttitle="AECO_LB")
length=input(defval=14, title="Stoch Scaling Length"), sl=input(defval=9, title="Signal Length")
ep=input(defval=5, title="Smooth Length")
vrb= abs( stoch(close, high, low, length)-50)/50
mep=2/(ep+1), ce=cum(1)<=((length+ep)*2)
came1=iff(ce,close-open,nz(came1[1])+mep*vrb*((close-open)-nz(came1[1])))
came2=iff(ce,high-low,nz(came2[1])+mep*vrb*((high-low)-nz(came2[1])))
came11=iff(ce,came1,nz(came11[1])+mep*vrb*(came1-nz(came11[1])))
came22=iff(ce,came2,nz(came22[1])+mep*vrb*(came2-nz(came22[1])))
eco=came11/came22*100.0
se=ema(eco, sl)
ebc=input(false, title="Enable Bar colors")
bc_=eco>0 ? (eco>eco[1]?green:orange) : (eco<eco[1]?red:orange)
bc_t=eco>0 ? (eco>se?lime:orange) : (eco<se?red:orange)
bc=ebc? bc_t : na
barcolor(bc)
plot(0, title="MidLine")
plot(eco, style=histogram, color=bc_,linewidth=2, title="ECOHisto_1")
plot(eco, color=black, linewidth=2, title="AECO")

well I presume that iff its the if statement but I get loss because I don't see the then and else, maybe nz is a substitution for that inside those lines?
Nothing to "convert" in "iif" statement. Like pinescript, in thinkscript "then" or "else" are implied with the use of commas.

nz means not zero, similar to IsNan

I know less than nothing about pinescript so I cannot convert for you. But the above is standard in many languages.
 
Here is both TrendFlex and Reflex with the overbought and oversold lines added, the cloud, and visuals to match the tradingview versions you referenced.


TrendFlex:
Code:
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def average = filter - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Trendflex = average / rms;
plot ZeroLine = 0;
#Trendflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# TrendFlex additions by bigboss
input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then TrendFlex else Double.NaN,Color.PLUM,color.PLUM);

TrendFlex.SetDefaultColor(Color.MAGENTA);
ZeroLine.SetDefaultColor(Color.WHITE);

TrendFlex.SetLineWeight(lineThickness);

ob.SetDefaultColor(color.RED);
os.SetDefaultColor(color.GREEN);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);

Reflex:
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2020-2021
#

declare lower;

input length = 20;

def filter = reference EhlersSuperSmootherFilter("cutoff length" = length / 2);
def slope = (filter[length] - filter) / length;
def average = filter + slope * (length + 1) / 2 - Sum(filter, length)[1] / length;
def rms = Sqrt(ExpAverage(Sqr(average), 50));

plot Reflex = average / rms;
plot ZeroLine = 0;

#Reflex.SetDefaultColor(color = Color.DOWNTICK);
#ZeroLine.SetDefaultColor(color = Color.GRAY);

# Reflex additions by bigboss

input showCloud = yes;
input lineThickness = 2;
input overBought = 1;
input overSold = -1;

plot ob = overBought;
plot os = overSold;

AddCloud(if showCloud then ZeroLine else Double.NaN,if showCloud then Reflex else Double.NaN,Color.YELLOW,Color.YELLOW);

ZeroLine.SetDefaultColor(Color.WHITE);
Reflex.SetDefaultColor(Color.YELLOW);

Reflex.SetLineWeight(2);

ob.SetDefaultColor(Color.RED);
os.SetDefaultColor(Color.GREEN);
os.SetPaintingStrategy(PaintingStrategy.DASHES);
ob.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
The TrendFlex will not work unless you add a # above the TD Ameritrade line.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
416 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