Extended Keltner Channels For ThinkOrSwim

cabe1332

Active member
I would like to share an alternative, which works for me very well, an extended Keltner channel on a chart. Similar to like a Bollinger band, it provides a wedge up or down signal when price action has overextended. It saves on real estate on your TOS chart. Code below and screenshot. Good luck! @cabe1332

# Extended Keltner Channels on chart
# @cabe1332
# credit to TOS Indicators
# provides wedge up or down when price action is overextended

# code start

input kcfactor = 3.0;

#plot extendedLong = close > keltnerChannels(factor = kcfactor).UpperBand;
plot extendedLong = close > keltnerChannels(factor = kcfactor).UpperBand and RSI() > 70;
#plot extendedshort = close < keltnerChannels(factor = kcfactor).LowerBand;
plot extendedshort = close < keltnerChannels(factor = kcfactor).LowerBand and RSI() < 30;

extendedLong.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
extendedShort.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
extendedLong.setDefaultColor(Color.pink);
extendedShort.setDefaultColor(Color.Light_green);

# code end
 
Last edited by a moderator:
Hello trying to get this indicator in an mtf version thanks


input KCFactor = 3.0;

plot extendedLong = close > KeltnerChannels(factor = KCFactor).UpperBand;
plot extendedShort = close < KeltnerChannels(factor = KCFactor).LowerBand;

extendedLong.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
extendedShort.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
extendedLong.setDefaultColor(Color.pink);
extendedShort.setDefaultColor(Color.Light_green);

assignpricecolor(if extendedlong then color.blue else if extendedshort then color.red else color.gray);
 
@Piper2808t,

https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AggregationPeriod
https://tlc.thinkorswim.com/center/...s/AggregationPeriod/AggregationPeriod-TEN-MIN

These links will get you a list of available aggregations and sample code like this:
Code:
def agg = AggregationPeriod.TEN_MIN;
plot data = close(period = agg);

You can rewrite the "def agg" to be "input agg", if you need to be able to change it on the fly
and then you may use the "data" series in place of "close" in your extendedLong and Short plots.

the inputs for the Keltner Channels is described here:
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/KeltnerChannels

which tells you that you need to change the KeltnerChannels() call to something like this:
Code:
... KeltnerChannels(factor = KCFactor, price = data) ...

If, that is, you want the Keltner Channel calculated on the secondary aggregation period.

If you try all of this and still can't sort it out, do come back and show us your code and we can help get it that 'last mile' to be what you need.

-mashume
 
Last edited:
@Piper2808t : Try this...

Code:
input KCFactor = 1.5;

input agg = AggregationPeriod.DAY;

plot extendedLong = close(period = agg) > KeltnerChannels(factor = KCFactor).Upper_Band;
plot extendedShort = close(period = agg) < KeltnerChannels(factor = KCFactor).Lower_Band;

extendedLong.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
extendedShort.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
extendedLong.setDefaultColor(Color.pink);
extendedShort.setDefaultColor(Color.Light_green);

assignpricecolor(if extendedlong then color.blue else if extendedshort then color.red else color.gray);

202301132212-KCtest.jpg


202301132214-KCtest.jpg


Hope this helps...

Good Luck and Good Trading :cool:
 
@mashume : Thank you for your excellent tutorial...FWIW, I think Schwab/TDA could spend some time and "enhance" their current TOS documentation along the lines of what you posted...

"Give a man a fish, and you feed him for a day; show him how to catch fish, and you feed him for a lifetime..."

 
@Piper2808t : Try this...

Code:
input KCFactor = 1.5;

input agg = AggregationPeriod.DAY;

plot extendedLong = close(period = agg) > KeltnerChannels(factor = KCFactor).Upper_Band;
plot extendedShort = close(period = agg) < KeltnerChannels(factor = KCFactor).Lower_Band;

extendedLong.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Up);
extendedShort.setPaintingStrategy(PaintingStrategy.Boolean_Wedge_Down);
extendedLong.setDefaultColor(Color.pink);
extendedShort.setDefaultColor(Color.Light_green);

assignpricecolor(if extendedlong then color.blue else if extendedshort then color.red else color.gray);

202301132212-KCtest.jpg


202301132214-KCtest.jpg


Hope this helps...

Good Luck and Good Trading :cool:
Works great thank you
 

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