Multi-Timeframe Keltner Channel (MTF) for ThinkorSwim

kingkunta

New member
Hi, in my trading i mostly use Multitimeframe keltner channels and would like to know if there is a way to show the ccurrent keltner bar for the time frame to be plotted instead of all the ones before it.

example:

cbnWPIh.png


the blue box represents the current 30 min keltner and the green represents the current 15min.

Any help is appreciated thank you!
 
Last edited:

BenTen

Administrative
Staff
VIP
Here is the Multiple Time Frame version of the Keltner Channel.

Code:
# MTF Keltner Channel
# Assembled by BenTen at UseThinkScript.com

declare weak_volume_dependency;

input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);

input displace = 0;
input factor = 1.5;
input length = 20;
def 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));
 

kingkunta

New member
Thanks ben for the quick response, but I'm actually wondering more about how to create kelts where it only plot the current 15min/30 min box period, such as the picture i posted above
 

Ryguy

New member
Here is the Multiple Time Frame version of the Keltner Channel.

Code:
# MTF Keltner Channel
# Assembled by BenTen at UseThinkScript.com

declare weak_volume_dependency;

input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def close = close(period = aggregationPeriod);

input displace = 0;
input factor = 1.5;
input length = 20;
def 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));
Ben you are awesome, but you probably know that already. :). quick inquiry for you. I put the indicator on my chart but haven't had any luck on getting the multitimeframe keltner channel to display on my charts. Im not sure what Im doing wrong. I tried changing the time frames on the indicator as well as my charts. I also tried changing the instruments to trade on with no luck. When you have a second will you help me out with this one? I appreciate you. Thank you Thank you.
 

rad14733

Well-known member
VIP
@Ryguy I just tried the Study and it works as expected if you match the aggregation period setting to match the timeframe of your chart... I tested multiple timeframes with matching aggregation periods and had no issues whatsoever with any of them...

However, the original question presented by the OP was never answered by @BenTen... So, while the code presented works, it doesn't work like the picture in the first post...

19zwMS6.png


Ys9ofH2.png
 

Ryguy

New member
@Ryguy I just tried the Study and it works as expected if you match the aggregation period setting to match the timeframe of your chart... I tested multiple timeframes with matching aggregation periods and had no issues whatsoever with any of them...

However, the original question presented by the OP was never answered by @BenTen... So, while the code presented works, it doesn't work like the picture in the first post...

19zwMS6.png


Ys9ofH2.png
My apologies. I did get it to work perfectly. thank you thank you :)
 

Similar threads

Top