Creating Label f/ Keltner Channel Percentage


New member
Hello & happy I've found this forum. I'd like to create a label which shows the % a daily candle is related to the Keltner channels bands for TOS.

Keltner Channel Calculation
There are three steps to calculating Keltner Channels. First, select the length for the exponential moving average. Second, choose the time periods for the Average True Range (ATR). Third, choose the multiplier for the Average True Range.

Middle Line: 21-day exponential moving average
Upper Channel Line: 21-day EMA + (2 x ATR(10))
Lower Channel Line: 21-day EMA - (2 x ATR(10))

Here is the code to a similar one which uses Bollinger Bands. I'm just not familiar with how to setup code in TOS.

input averageType = AverageType.Simple;
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

DefineGlobalColor("Neutral", color.gray);

def BPB = BollingerPercentB(averageType = averageType,price = price, displace = displace, length = length, Num_Dev_Dn = Num_Dev_Dn, Num_Dev_up = Num_Dev_up).PercentB;

AddLabel(Yes, "Bol%B(" + length + "):" + round(BPB,1), if BPB > 90 then GlobalColor("High") else if BPB < 10 then GlobalColor("Low") else GlobalColor("Neutral"));
Last edited:


New member
I was wondering if there i any way to come up with a keltner channel label percentage displaying factors with the length 14 and the with both average type and true range average type Exponential. Thanks in advance

Similar threads