TOS Scan - Above / Below Keltner Channels

Lone Wolf

New member
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!
 

BenTen

Administrative
Staff
VIP
You can do that by setting up your scanner to something like this:

Here is an example: close crosses above the Upper Band.

aQwRD23.png
 

BenTen

Administrative
Staff
VIP
@Lone Wolf Here you go:

Code:
# KeltnerChannels
# TD Ameritrade IP Company, Inc. (c) 2007-2020
# Modified by BenTen at UseThinkScript.com
# Added paintbars

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 close > Upper_Band then color.green else if close < Lower_Band then color.red else color.white);
 

rad14733

Well-known member
VIP
@ssimonn So you want to know when price crosses either of the "Keltner Channels"...???

Ruby:
plot kcx = if close crosses above KeltnerChannels()."Upper_Band" then 1
                 else if close crosses below KeltnerChannels()."Lower_Band" then -1
                 else Double.NaN;
 
Last edited:

cswu1211

Member
VIP
You can do that by setting up your scanner to something like this:

Here is an example: close crosses above the Upper Band.

aQwRD23.png
Dear Ben: I use #4 thread that you post to scan for {close cross above Upper Keltner band}. However, after checking the scan results, The charts don't seem to fit the scan criteria. Could you help explain
VIj08iT.png

R2jp1ae.png

ctJVHLt.png
 

Similar threads

Top