本策略名称为“基于动量指标的短期交易策略”。该策略利用动量指标Mass Index来识别市场趋势的转折点,以捕捉短期交易机会。
该策略使用两组不同参数的指数移动平均线EMA来平滑价格的最高价和最低价的差值,得到指标Mass Index。当Mass Index上穿某一阈值时做空;当Mass Index下穿某一阈值时做多。
具体来说,首先计算最高价和最低价的差值xPrice。然后计算xPrice的9周期和25周期的EMA,分别命名为xEMA和xSmoothXAvg。接着计算这两个EMA的比值之和,得到Mass Index。当Mass Index大于某个阈值时做空,小于某个阈值时做多。
该策略利用Mass Index的上下突破来判断趋势转折点,从而进行短期交易。当市场震荡加剧时,Mass Index将上升;当市场震荡减弱时,Mass Index将下降。监测其突破某一水平可以有效捕捉到短期交易机会。
该策略具有如下优势:
该策略也存在一些风险:
该策略可从以下几个方面进行优化:
本策略基于Mass Index指标设计了一个较为简单的短期交易策略,可以有效识别市场的转折点,从而精确做多做空。该策略交易策略和参数设置简单直观,容易实施,且可根据不同市场环境进行调整优化,具有较强的实用性。但也应注意数据过拟合和指标失效的风险,需结合趋势判断和止损措施来应对市场的不确定性。
/*backtest start: 2023-02-20 00:00:00 end: 2024-02-26 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 12/09/2017 // The Mass Index was designed to identify trend reversals by measuring // the narrowing and widening of the range between the high and low prices. // As this range widens, the Mass Index increases; as the range narrows // the Mass Index decreases. // The Mass Index was developed by Donald Dorsey. // // You can change long to short in the Input Settings // WARNING: // - For purpose educate only // - This script to change bars colors. //////////////////////////////////////////////////////////// strategy(title="MASS Index", shorttitle="MASS Index") Length1 = input(9, minval=1) Length2 = input(25, minval=1) Trigger = input(26.5, step = 0.01) reverse = input(false, title="Trade reverse") hline(27, color=blue, linestyle=line, title = "Setup") hline(Trigger, color=red, linestyle=line, title = "Trigger") xPrice = high - low xEMA = ema(xPrice, Length1) xSmoothXAvg = ema(xEMA, Length1) nRes = sum(iff(xSmoothXAvg != 0, xEMA / xSmoothXAvg, 0), Length2) pos = iff(nRes > Trigger, -1, iff(nRes < Trigger, 1, nz(pos[1], 0))) possig = iff(reverse and pos == 1, -1, iff(reverse and pos == -1, 1, pos)) if (possig == 1) strategy.entry("Long", strategy.long) if (possig == -1) strategy.entry("Short", strategy.short) barcolor(possig == -1 ? red: possig == 1 ? green : blue ) plot(nRes, color=red, title="MASS Index")