Keltner Channel Strategy - Need help Coding

Lone Wolf

New member
Plus
Hi,

Does anybody know if I can scan using TOS for stocks where the body of the candle is COMPLETELY above or below the upper/lower Keltner Channel (using length 20, and 2.25 ATR)?

I see there are criteria for Bollinger bands there, but I am looking to scan for stocks where the body is completely outside the Keltner channel.

Let me know.

Thanks!
 
can you edit your post and rewrite your rules to clarify a few things.

what does closes about mean?
...price closes about the


what does this mean? upper channel is a line. there is no close.
...Following the close of the upper channel,


... buy when price crosses back below the upper channel,


not sure on this, what is prior period?
and is equal to or below the value of the prior periods moving average value.
Just tried to clarify as best as possible with a picture.

let me know if that makes sense.
 
by MA you mean the 20-period avg MA line? that's pretty much the way i've been trading recently but i do it visually, have not set it up as a strategy. yours varies from mine in several ways but over it, well, it's been working pretty well. be interested to see what results a coded strategy spits out, probably pretty ugly in a determined downtrend and not so great in a furious uptrend but in between those two, should be okay.
 
by MA you mean the 20-period avg MA line? that's pretty much the way i've been trading recently but i do it visually, have not set it up as a strategy. yours varies from mine in several ways but over it, well, it's been working pretty well. be interested to see what results a coded strategy spits out, probably pretty ugly in a determined downtrend and not so great in a furious uptrend but in between those two, should be okay.
yes, 20 pd MA line.

I am really just looking to create this for proof of validation. I would never just take the signals blindly.
 
Hey all,

Could somebody help me code a Keltner Channel indicator where the candles are just the normal green/red color and then when a candle closes outside an upper or lower band it is painted white?

Screenshot 2023-06-22 at 6.37.29 PM.png
 
Last edited:
i do it fairly blindly -- ok a lot blindly -- and so far so good, just the swings between the bands, using 3x ETFs. use keltners set at 1, 2, and 3 and never buy above the 20EMA line.
 
Sure. It looks like you're only considering the bar "poking" through the channel and not the whole bar being outside, so this should work. If you wanted it to include the whole bar you'd have to flip-flop the high and low. Otherwise this will work for you. I'm using the default Keltner Channel study from ToS.


Ruby:
declare weak_volume_dependency;

input displace = 0;
input factor = 1.5;
input length = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);

def average = MovingAverage(averageType, price, length);

plot Avg = average[-displace];
Avg.SetDefaultColor(GetColor(1));

plot Upper_Band = average[-displace] + shift[-displace];
Upper_Band.SetDefaultColor(GetColor(8));

plot Lower_Band = average[-displace] - shift[-displace];
Lower_Band.SetDefaultColor(GetColor(5));

AssignPriceColor(
    if high > Upper_Band or low < Lower_Band then Color.WHITE
    else Color.CURRENT
);
 
Hey all, I am looking to try to code this Keltner Channel strategy but I've ran into a few issues.

Here is what I am looking to code.

Keltner channel settings, 20 period, 2.25 factor, exponential
MACD Settings - 3,10,16, Simple MA

Rules for buy entries
  1. price closes about the upper Keltner channel
  2. Following the close of the upper channel, buy when price crosses back below the upper channel, and the MACD signal line is less than 0.
  3. Exit at the most recent pivot high.

The above link shows an example of an ideal trade. Price breaks above the upper Keltner, comes back below and MACD signal line is less than zero. Once entered, look to exit at the most recent high.
 

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