Name
基于移动平均线跨度的反转交易策略Reversal-Trading-Strategy-Based-on-Moving-Average-Range
Author
ChaoZhang
Strategy Description
该策略命名为“移动平均线跨度反转”,它通过计算不同周期移动平均线之间的交叉情况,判断行情反转的时机,采取适当的做多做空操作。
该策略同时计算3条移动平均线,分别是:
- 快速移动平均线(周期参数flenght):反映最新价格变化
- 慢速移动平均线(周期参数llenght):反映中期价格走势
- 最慢速移动平均线(周期参数sslenght):反映长期价格趋势
当快速移动平均线从下方上穿慢速移动平均线时,说明短期行情开始反转为多头;当快速移动平均线从上方下穿慢速移动平均线时,说明短期行情开始反转为空头。
为了过滤假突破,策略还引入了第4条移动平均线,即长期趋势过滤器(周期参数tlenght)。只有当价格处于该移动平均线之上时,才考虑做多信号;只有当价格处于该移动平均线之下时,才考虑做空信号。
具体交易规则如下:
-
当快速移动平均线上穿慢速移动平均线,而慢速移动平均线又上穿最慢速移动平均线时(短期多头信号),同时价格高于长期趋势过滤器时,做多入市;当快速移动平均线下穿慢速移动平均线时,平掉多头仓位。
-
当快速移动平均线下穿慢速移动平均线,而慢速移动平均线又下穿最慢速移动平均线时(短期空头信号),同时价格低于长期趋势过滤器时,做空入市;当快速移动平均线上穿慢速移动平均线时,平掉空头仓位。
该策略具有以下优势:
- 利用多时间框架分析,能有效识别短中长期价格趋势的变化,减少假信号。
- 引入长期趋势过滤器,能够避免在长期趋势变化前的错位交易。
- 交易规则简单清晰,容易理解实现,适合量化交易。
- 反转策略具有正偏回报率和利润的优势。
- 实盘模拟回测效果良好,收益和盈利因子都不错。
该策略也存在以下风险:
- 移动平均线策略对参数敏感,不同参数会产生不同的结果。
- 反转信号可能出现假突破,从而引发交易亏损。
- 行情可能出现长期震荡,多次反转让利润归零。
- 反转后价格可能出现强劲突破,无法及时止损退出。
解决方法:
- 优化参数,找到最佳参数组合。
- 适当延长反转信号的确认时间,避免假突破。
- 加大止损幅度,降低亏损风险。
该策略还可从以下方面进行优化:
- 测试更多参数组合,寻找最优参数。
- 增加成交量过滤,避免低量假突破。
- 结合其他指标确认进场信号。
- 动态调整止损位置,优化退出机制。
- 优化资金管理策略,控制风险。
该策略基于移动平均线的金叉死叉进行反转交易,同时引入长期趋势过滤器指导交易方向,能有效识别市场反转时机。从回测结果看,该策略收益性较好,有一定的实盘应用价值。后续可从参数选择、指标过滤、止损机制等方面进行优化,使策略更加稳健实用。
||
This strategy is named "Moving Average Range Reversal". It identifies market reversal opportunities by calculating crossovers between moving averages of different timeframes and takes appropriate long/short positions.
The strategy computes 3 moving averages simultaneously:
- Fast MA (flenght): Reflecting latest price changes
- Slow MA (llenght): Reflecting mid-term price trends
- Slowest MA (sslenght): Reflecting long-term price tendencies
When fast MA crosses above slow MA, it signals a short-term trend reversal to bullish. When fast MA crosses below slow MA, it signals a short-term reversal to bearish.
To avoid false signals, a 4th MA is introduced as the long-term filter (tlenght). Only above this filter long signals are considered. Only below this filter short signals are considered.
The specific trading rules are:
-
When fast MA crosses above slow MA, and slow MA also crosses above slowest MA (short-term bullish), while price is above the long-term filter, go long. When fast MA crosses below slow MA, close long position.
-
When fast MA crosses below slow MA, and slow MA also crosses below slowest MA (short-term bearish), while price is below the long-term filter, go short. When fast MA crosses above slow MA, close short position.
The advantages of this strategy include:
- Utilizing multiple timeframes to identify trend changes more precisely and reduce false signals.
- Long-term filter avoids mispositioned trades before major trend reversal.
- Simple and clear rules, easy to understand and automate.
- Reversal strategies benefit from positive bias in returns and profits.
- Good backtest results in simulated live trading regarding returns and profit factor.
The risks of the strategy include:
- MA strategies are sensitive to parameters. Different parameters lead to different results.
- False breakout of reversal signals may cause losses.
- Prolonged sideways may nullify profits from repeated reversals.
- Price may reverse and accelerate with strength, failing timely stop loss.
Solutions:
- Optimize parameters to find best combination.
- Increase signal confirmation time to avoid false signals.
- Expand stop loss range to control loss amount.
The strategy can be improved in the following aspects:
- Test more parameter sets to find optimum values.
- Add volume filter to avoid false signals in low volume conditions.
- Incorporate other indicators to confirm entry signals.
- Implement dynamic adjustment of stop loss for better exit control.
- Optimize risk management for tighter risk control.
This strategy trades market reversals identified by MA crossovers, with direction guidance from the long-term filter. It effectively captures opportunities at turning points. The positive backtest results show good profitability for live application. Further optimizations on parameters, signal filtering, stop loss etc. can make the strategy more robust for practical use.
[/trans]
Strategy Arguments
Argument | Default | Description |
---|---|---|
v_input_int_1 | 3 | Fast MA Period |
v_input_int_2 | 5 | Slower MA Period |
v_input_int_3 | 8 | Slowest MA Period |
v_input_int_4 | 200 | Trend Filter MA Period |
Source (PineScript)
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Moving Average Trap", overlay=true)
flenght = input.int(title="Fast MA Period", minval=1, maxval=2000, defval=3)
llenght = input.int(title="Slower MA Period", minval=1, maxval=2000, defval=5)
sslenght = input.int(title="Slowest MA Period", minval=1, maxval=2000, defval=8)
tlenght = input.int(title="Trend Filter MA Period", minval=1, maxval=2000, defval=200)
ssma = ta.sma(close, sslenght)
fma = ta.sma(close, flenght)
sma = ta.sma(close, llenght)
tma = ta.sma(close, tlenght)
plot(fma, color=color.red)
plot(sma, color=color.white)
plot(ssma, color=color.green)
plot(tma, color=color.maroon, linewidth=2)
short = (fma > sma and sma > ssma) and close < tma
long = (fma < sma and sma < ssma) and close > tma
closeshort = fma < sma and sma < ssma
closelong = fma > sma and sma > ssma
if long
strategy.entry("long", strategy.long)
if closelong
strategy.close("long")
if short
strategy.entry("short", strategy.short)
if closeshort
strategy.close("short")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
Detail
https://www.fmz.com/strategy/439973
Last Modified
2024-01-25 14:16:28