KAMA Strategy - Kaufman's Adaptive Moving Average

BenHampson アップデート済   
This strategy combines Kaufman's Adaptive Moving Average for entry with optional KAMA , PSAR, and Trailing ATR stops for exits.

Kaufman's Adaptive Moving Average is, in my opinion, a gem among the plethora of indicators. It is underrated considering it offers a solution that intuitively makes a lot of sense. When I first read about it, it was a real 'aha!' moment. Look at the top, pink line. Notice how during trending times it follows the trend quickly and closely, but during choppy, non-trending periods, the KAMA stays absolutely flat? Interesting! To trade with it, we simply follow the direction the KAMA is pointing. Is it up? Go long. Is it down? Go short. Is it flat? Hold on.

How does it manage to quickly follow real trends like a fast EMA but ignore choppy conditions that would whipsaw a fast EMA back and forth? It analyses whether recent price moves are significant relative to recent noise and then adapts the length of the EMA window accordingly. If price movement is big compared to the recent noise, the EMA window gets smaller. If price movement is relatively small or average compared to the recent noise, the EMA window gets bigger. In practice it means:

  • The KAMA would be flat if a 20 point upwards move occurred during a period that has had, on average, regular 20 point moves BUT
  • the KAMA would point up if a 20 point move occurred during a period that has, on average, had moves of only around 5 points.

In other words, it's a slow EMA during choppy flat / quiet flat periods, and a fast EMA as soon as significant volatility occurs. Perfect!


The Strategy
The strategy is more than just a KAMA indicator. It contains:

  • KAMA exit (optional)
  • ATR trailing stop loss exit (optional)
  • PSAR stop loss exit (optional)
  • KAMA filter for entry and exits
  • All features are adjustable in the strategy settings

The Technical Details:
Check out the strategy's 'Inputs' panel. The buy and sell signals are based on the 'KAMA 1' there.
  • KAMA 1: Length -- 14 is the default. This is the length of the window the KAMA looks back over. In this instance, it c
  • KAMA 1: Fast KAMA Length -- 2 is the default. This is the tightest the EMA length is allowed to get. It will tend towards this length when volatility is high.
  • KAMA 1: Slow KAMA Length -- 20 is the default. This is the biggest the EMA length is allowed to get. It will tend towards this length when volatility is low.

KAMA Filter
The strategy buys when the KAMA begins to point up and sells when the KAMA points down. Generally, the KAMA is very good at filtering out the noise itself - it will go flat during noisy/choppy periods. But to add another layer of safety, its author, Perry Kaufman, proposed a KAMA filter. It works by taking the standard deviation of returns over the length of the the 'KAMA 1: Length' I mentioned above and multiplying it by an 'Entry Filter' (1 by default) and 'Exit Filter' (0.5 by default). The entry condition to go long is that the KAMA is pointing up and and it moved up more than 1 x St. Dev. of Returns. The exit condition is when the KAMA is pointing down and it moved down by more than 0.5 x St. Dev. of Returns.

Thanks to ChuckBanger, cheatcountry, millerrh, and racer8 for parts of the code. I was able to build upon their good work.


I hope this strategy is helpful to you.

Do you have any thoughts, ideas, or questions? Let me know in the comments or send me a message! I'd be glad to help you out.

If you need an indicator or strategy to be built or customised for you, let me know! I'll be glad to help and it'll probably be cheaper than you think!
Updated to v5.


TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。