资源加载中... loading...

K的反转指示器I

Author: 雨幕(youquant), Date: 2022-06-07 15:53:59
Tags: smaEMA

K的反转指示器I是布林带和MACD振荡器之间的特殊组合。这是一个反向指标,取决于以下条件:

•只要当前市场价格低于100个周期的较低布林带,就会产生买入信号,同时MACD值必须高于其信号线。同时,以前的MACD值必须低于以前的信号线。 •当当前市场价格高于100个周期的布林上限时,就会产生卖出(做空)信号,同时,MACD值必须低于其信号线。同时,先前的MACD值必须高于其先前的信号线。

使用K反转指标的方法是将其与横向/区间市场中已经存在的多头/空头偏差相结合,以最大限度地提高成功的概率。

该指标的局限性包括: •没有明确的退出规则可以在整个市场上正常运行。尽管K的反转指标给出了反转信号,但它并没有显示何时退出头寸。 •与其他指标一样,它在某些市场表现不佳,不能在任何地方使用。 •在趋势市场期间,往往会出现错误信号,但没有行之有效的方法来检测错误信号。

回测测试

img

img

img


/*backtest
start: 2021-05-31 09:00:00
end: 2022-06-06 15:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["ContractType","rb888",360008]]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar

//@version = 5
indicator("K's Reversal Indicator I", overlay = true)

fast       = input(defval = 12, title = '快线')
slow       = input(defval = 26, title = '慢线')
signal     = input(defval = 9,  title = '信号')
length     = input(defval = 100, title = 'Bollinger 回看周期')
multiplier = input(defval = 2,  title = '乘数')

// MACD
macd_line   = ta.ema(close, fast) - ta.ema(close, slow)
signal_line = ta.ema(macd_line, signal)

// Bollinger
lower_boll = ta.sma(close, length) - (multiplier * ta.stdev(close, length))
upper_boll = ta.sma(close, length) + (multiplier * ta.stdev(close, length))
mid_line = ta.sma(close, length)

// Signal
buy_signal  = math.min(open[1], close[1]) <= lower_boll[1] and math.max(open[1], close[1]) <= mid_line and macd_line[1] > signal_line[1] and macd_line[2] < signal_line[2]
sell_signal = math.max(open[1], close[1]) >= upper_boll[1] and math.min(open[1], close[1]) >= mid_line and macd_line[1] < signal_line[1] and macd_line[2] > signal_line[2]

if buy_signal
    strategy.entry("Enter Long", strategy.long)
else if sell_signal
    strategy.entry("Enter Short", strategy.short)
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6