TradingView
DojiEmoji
2021년 10월 7일 오후 1시 42분

Kaufman's Efficiency Ratio Strategy [KL] 

Apple Inc.NASDAQ

설명

I recently published an indicator called "Kaufman's Efficiency Ratio Indicator". In the description of that script, I hypothesized about how the Efficiency Ratio could be applied to identify bullish moves in instances where price had already gone up steeply, but rests for a while, allowing for entry in expectation that price will continually rise. I decided to test out this idea with Pinescript.

About Kaufman's Efficiency Ratio ("ER")
ER was developed by a systematic trader by the name of Perry J. Kaufman.

Formula
The formula is:
= A divided by B,
where:
  • A = Current closing price minus the closing price at the start of the lookback period
  • B = Sum of differences between closing prices (in absolute terms) of consecutive bars over the lookback period


How this strategy enters a trade (Long):
- code: entry_signal_long = ER > 0 and ER_is_mid
- meaning: when ER is positive, strategy assumes price has risen. Usually ER value begins high (red), and unless it is a false move, then it should stay positive. This strategy will patiently wait until ER drops to medium (yellow), and then place a trade.
- how low/medium/high is dynamically determined: Refer to the description of my other script("Kaufman's Efficiency Ratio Indicator") for details. Trying to keep this as short as possible.

How this strategy exits a trade (Long):
- when price hits stop limit; stop limit is based on low of bars, trails upward based on ATR
- included a feature called "tightening TSL", which tries to reduce the stop-buffer during periods of high volatility implied by ER (very experimental, opening the floor for suggestions on how this can be improved)

릴리즈 노트

Added profit taking levels. Also amended risk management aspects the strategy.
Changes:
- Order size is based on user-defined percentage of committed capital
- Profit taking over 3 levels based on risk to reward ratio (i.e. 1R, 2R, 3R). When a target is met at each tier, strategy will close out one third of current position size. Unreached targets will eventually be closed at the trailing stoploss price.

릴리즈 노트

(a) Fixed a bug relating to profit taking over 3 levels (described in the previous update), and (b) refactored other parts of the codes to have (neat spacings, better variable names, etc).

릴리즈 노트

(a) Added short (default not used), and (b) removed: entry confirmation checking for ER being low/mid/high. Through backtests, noticed better results when not using it.
코멘트
pmk07
Impressive results! Looks like line 122 initial_order_size := math.floor(pcnt_alloc * strategy.equity / close) - significantly limits entries if the asset has a high unit value (e.g. BTC has no any trades on default script settings). Another thought about the script - it is a breakeout strategy - therefore for correct result probably you should test it in the markets without bullish trend, otherwise with a bullish movement there will often be an upward breakout and continuation of the movement, which will give good results for breakout longonly strategy. Overall, thanks for sharing your work!
DojiEmoji
@pmk07, Thank you for the feedback. Will consider implementing short in the next update.

I know you know why high value assets don't get traded, but I'll still type it here for others reading this to understand:

TradingView's backtester does not support fractional shares (or if you want to call it crypto), so the strategy must buy at least 1 BTC per trade. Since the default allocation is 5% of USD100k initial capital, it likely didn't have enough cash buy 1BTC priced during beginning of backtest period.

To everyone wanting to Backtest with BTC on default 5% prcnt_alloc: you'll need to set initial capital higher (say at amount = BTC price / 0.05). Alternatively, you could take an aggressive approach by increasing 'prcnt_alloc'. All depends on you risk tolerance level.
erickxs
-removed by the author-
pmk07
hi. thank you for the good study. I have tried it and found that it's not giving any short signals. entry_signal_short = false in code. Is there any limits on using ER for shorting?
DojiEmoji
@pmk07, Thanks for checking it out.

I've not backtested shorting with this indicator yet, can't say about the limitations.

On the other hand, this script supports shorting, just that it's currently turned off. "Equals false" tells the program to ignore the signal. Users are welcomed to tinker around with this line of code to test shorting.
더보기