一种新的量化交易策略,该策略主要基于DMI指标来识别行情的底部和顶部。本文将详细介绍该交易策略的原理、优势以及可能存在的风险。
DMI指标全称为平均趋向指标(Average Directional Movement Index),它由 Welles Wilder 在20世纪70年代提出,用于判断市场的趋势和力度。DMI指标由三条线组成:
当+DI上穿-DI时,代表涨势加强,可以考虑做多;当-DI上穿+DI时,代表跌势加强,可以考虑做空。
本策略的核心逻辑是:
也就是说,当反向DI线显著强于正向DI线时,可以判断目前的趋势即将反转,这时就可以适当介入进行反向操作。
为了过滤错乱情况,本策略采用DI的均线,具体参数设置为:
通过调整均线参数来控制交易信号的频繁程度。
本策略主要应用于NIFTY50指数期权交易,也可用于其他品种。具体交易时,选择平值期权,止损设置为20%,若亏损超过10%则加仓,但若亏损扩大至超过最初投入资金的20%则止损出局。
相比简单的DI交叉策略,本策略采用DI指标的均线过滤,可以有效减少whipsaw,并且减少交易次数,从而降低交易成本和滑点损失。
相比单纯的趋势跟踪策略,本策略在判断趋势反转点时比较精确,可以及时捕捉转折点附近的交易机会。
本策略参数优化比较简单,容易实现效果优化。
本策略仅给出交易信号的方向,具体的止损止盈要求需要按照个人风险偏好来设置。
DMI指标在盘整区域时可能产生大量假信号,应该避免在非趋势性市场中使用本策略。
DI交叉并不能百分之百预测趋势转折点,存在一定的时序错误。应适当结合其他指标来验证交易信号。
本策略通过DI均线的筛选,可以有效识别趋势反转机会。相比其他趋势跟踪策略,具有反转识别能力更强的优点。总体来说,本策略参数优化灵活,适合作为量化交易体系的一个模块来使用。使用时需要注意防范误信号,并适当评估市场趋势态势。
/*backtest
start: 2023-09-05 00:00:00
end: 2023-09-12 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © email_analysts
// This code gives indication on the chart to go long based on DMI and exit based on RSI.
//Default value has been taken as 14 for DMI+ and 6 for RSI.
//@version=5
strategy(title="DMI Strategy", overlay=false)
lensig = input.int(11, title="ADX Smoothing", minval=1, maxval=50)
len = input.int(11, minval=1, title="DI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
//plot(adx, color=#F50057, title="ADX")
plot(plus, color=color.green, title="+DI")
plot(minus, color=color.red, title="-DI")
hlineup = hline(40, color=#787B86)
hlinelow = hline(10, color=#787B86)
buy = plus < 10 and minus > 40
if buy
strategy.entry('long', strategy.long)
sell = plus > 40 and minus < 10
if sell
strategy.entry('short', strategy.short)