TOS Scan - Above / Below Keltner Channels

L

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

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.

 
L

Lone Wolf

New member
Thanks, Ben.

What about an indicator that would paint bars that are completely outside the upper/lower channel?
 
BenTen

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);
 

Similar threads

Top