双EMA价格摆动策略通过计算两个不同期限的EMA之间的差值,来判断市场的多空态势和力度。当快线和慢线之间差值上穿0时为看涨信号。当快线和慢线之间差值下穿0时为看跌信号。
该策略简单易用,通过EMA的差值判断市场力度和方向。但是也存在一定的滞后性,无法及时捕捉turning point。
双EMA价格摆动策略的核心指标是APO,即Absolute Price Oscillator,表示两个EMA之间的差值。其计算公式如下:
APO = EMA(短期) - EMA(长期)
具体来说,本策略中APO的计算为:
xShortEMA = ema(收盘价, LengthShortEMA)
xLongEMA = ema(收盘价, LengthLongEMA)
xAPO = xShortEMA - xLongEMA
其中LengthShortEMA和LengthLongEMA分别代表短期和长期EMA的周期长度。
APO几个关键判断规则:
根据APO的实时值来判断市场的多空状态和进入时机。
双EMA价格摆动策略具有以下几个主要优势:
双EMA价格摆动策略也存在一些风险,主要体现在:
可以通过合理止损,降低单笔亏损;优化参数,适应不同周期;结合其他指标过滤信号,提高策略稳定性,来应对和降低这些风险。
双EMA价格摆动策略主要可以从以下几个方向进行优化:
优化EMA周期参数,分别测试长度为5到60的EMA组合,找到最优参数
加入MA,KDJ,MACD等其他指标,设置过滤条件,避免假信号
利用布林带,KD等指标确定合理止盈止损位置
结合趋势指数等指标,判断价格趋势,避免逆势交易
加入交易量指标,确保有成交量支撑的突破信号
设定再入场条件,避免频繁交易,减少交易次数
综上所述,双EMA价格摆动策略通过计算两个EMA的差值APO来判断市场多空状态,策略信号简单清晰,实用性强,也存在一定弊端。我们可以通过参数优化、过滤条件新增、止损止盈设置等方法来优化和提高策略稳定性。该策略易于上手使用,也有很大的拓展空间,适合量化交易初学者学习和应用。
/*backtest start: 2023-02-19 00:00:00 end: 2024-02-25 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 30/05/2017 // The Absolute Price Oscillator displays the difference between two exponential // moving averages of a security's price and is expressed as an absolute value. // How this indicator works // APO crossing above zero is considered bullish, while crossing below zero is bearish. // A positive indicator value indicates an upward movement, while negative readings // signal a downward trend. // Divergences form when a new high or low in price is not confirmed by the Absolute Price // Oscillator (APO). A bullish divergence forms when price make a lower low, but the APO // forms a higher low. This indicates less downward momentum that could foreshadow a bullish // reversal. A bearish divergence forms when price makes a higher high, but the APO forms a // lower high. This shows less upward momentum that could foreshadow a bearish reversal. // // You can change long to short in the Input Settings // Please, use it only for learning or paper trading. Do not for real trading. //////////////////////////////////////////////////////////// strategy(title="Absolute Price Oscillator (APO) Backtest", shorttitle="APO") LengthShortEMA = input(10, minval=1) LengthLongEMA = input(20, minval=1) reverse = input(false, title="Trade reverse") hline(0, color=gray, linestyle=line) xPrice = close xShortEMA = ema(xPrice, LengthShortEMA) xLongEMA = ema(xPrice, LengthLongEMA) xAPO = xShortEMA - xLongEMA pos = iff(xAPO > 0, 1, iff(xAPO < 0, -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(xAPO, color=blue, title="APO")