# Kaufman Efficiency Ratio Indicator

L

#### Lauri

##### New member
VIP
@BenTen , is there a code for this in the thinkorswim forum. I read on Google there was, but I can't seem to find it.

Thanks,

Lauri

T

#### tomsk

##### Well-known member
VIP
@Lauri I have a copy of the Kaufman Efficiency Ratio from Mobius posted some time ago. Here t'is. Have fun

Code:
``````# Kaufman Efficiency Ratio
# Mobius
# 1.29.2017

# Here's the Kaufman Efficiency Ratio that the Kaufman AMA is based on.
# Notes: Price at extremes are entry / exit signals. Price in zone between extremes and equity should be avoided.

declare lower;

input n = 10;

def netchg = close - close[n];
def sumchg = sum(AbsValue(close - close[1]), n);
plot KER = (netchg / sumchg);
KER.SetStyle(Curve.Firm);
KER.SetDefaultColor(Color.Cyan);
plot zero = if isNaN(close) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
plot OB = HighestAll(KER) * .8;
OB.SetDefaultColor(Color.red);
plot OS = LowestAll(KER) * .8;
OS.SetDefaultColor(Color.green);
# End Code Kaufman Efficiency Ratio``````

L

#### Lauri

##### New member
VIP
Great! Can you tell me how to add a permanent line at the (-55) level? This is Awesome!

Thanks

Lauri

#### horserider

##### Well-known member
VIP
Better rethink that -55.

#### BenTen

Staff
VIP
@Lauri Like @horserider said, you might want to reconsider adding the -55 level. Maybe you want -0.5? In anyhow, to add a new line to that script, use the following snippet.

Code:
``plot Ob55 = -55;``

T

#### tomsk

##### Well-known member
VIP
Great! Can you tell me how to add a permanent line at the (-55) level? This is Awesome!

Thanks

Lauri

@Lauri Just checking in and saw your query.
Please note that this study is an oscillator with values between -1 and +1
The middle line is 0
If you'd like to add a permanent line at -55, you certainly can do that but in so doing the display would be squished or compressed.

As @BenTen and @horserider pointed out earlier they would not do that.

Just look at the oscillator values and decide if you still would like to plot any additional lines
One possible enhancement I could think of is to color code the oscillator where it is say yellow above the 0 line and red is under the 0 line
Have fun and if you'd need additional assistance, let me know

D

#### diazlaz

##### Well-known member
2019 Donor
VIP
very nice! - let me start.. - cross overs anyone anyone

this adds a Kalman Filter over the ratio. quite interesting when filter crosses the ratio.

plot Kalman = WMA(((WMA(KER, 3) * 3) + (WMA(KER[1], 2) * 2) + KER[2] + Average(KER, n)) / 7, n);

C

#### Chimera777

##### New member
What does this indicator do guys?

T

#### tomsk

##### Well-known member
VIP
@diazlaz Indeed, Kalman is a quadratic function that smoothens the data plots

#### horserider

##### Well-known member
VIP
Chimera As far as I can tell it does nothing that the well accepted RSI or stochastic or many others do. I would just stick with those two mentioned.
Congrats to diazlaz for a great addition if you are interested in using the Kalman.

L

#### Lauri

##### New member
VIP
@BenTen Thanks for all the input. I will try them and let you know.

Thanks,

Lauri

@tomsk yes, I carried waaaay too many ones! LOL I meant .55. Nice catch.

#### horserider

##### Well-known member
VIP
@Lauri Just thew the -.55 and diazlaz addition at the end of the study without trying to make it look pretty.

Code:
``````# Kaufman Efficiency Ratio
# Mobius
# 1.29.2017

# Here's the Kaufman Efficiency Ratio that the Kaufman AMA is based on.
# Notes: Price at extremes are entry / exit signals. Price in zone between extremes and equity should be avoided.

declare lower;

input n = 10;

def netchg = close - close[n];
def sumchg = sum(AbsValue(close - close[1]), n);
plot KER = (netchg / sumchg);
KER.SetStyle(Curve.Firm);
KER.SetDefaultColor(Color.Cyan);
plot zero = if isNaN(close) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
plot OB = HighestAll(KER) * .8;
OB.SetDefaultColor(Color.red);
plot OS = LowestAll(KER) * .8;
OS.SetDefaultColor(Color.green);
# End Code Kaufman Efficiency Ratio

plot ff = -.55;
ff.SetDefaultColor(Color.LIGHT_GRAY);

plot Kalman = WMA(((WMA(KER, 3) * 3) + (WMA(KER[1], 2) * 2) + KER[2] + Average(KER, n)) / 7, n);``````

#### markos

##### Well-known member
VIP
Chimera As far as I can tell it does nothing that the well accepted RSI or stochastic or many others do. I would just stick with those two mentioned.
Congrats to diazlaz for a great addition if you are interested in using the Kalman.
@horserider this is very true, There are over 300-400 built in indicators and yet we can't seem to get enough until we find 1 or 7 or 9 that speak to us. Problem is, they don't all fit on the chart. Many say the same thing, just differently! One good thing about this site is the excersize of indicator creation which has helped me, here and on other sites, to know that what I use suits me.

L

#### Lauri

##### New member
VIP
Thank you All for your help on this!

W

#### WayneG

##### New member
VIP
I've found numerous references to this indicator, including one about translating from the TOS version to TradeStation. I know that we have the lower half of the indicator, but I'm looking for the full version that plots on the main chart too.]

Thanks for the help, Wayneg

Last edited: