210 lines
4.6 KiB
Markdown
210 lines
4.6 KiB
Markdown
|
|
> Name
|
|
|
|
基于均线交叉的趋势反转策略MA-and-EMA-Crossover-Trend-Reversal-Strategy
|
|
|
|
> Author
|
|
|
|
ChaoZhang
|
|
|
|
> Strategy Description
|
|
|
|
[trans]
|
|
|
|
## 概述
|
|
|
|
该策略利用EMA和MA均线的交叉来判断趋势反转,属于典型的趋势跟踪策略。
|
|
|
|
## 策略原理
|
|
|
|
1. 分别计算指定周期的EMA指数均线和MA简单移动均线。
|
|
|
|
2. 当EMA从下方上穿MA时,产生买入信号。
|
|
|
|
3. 当EMA从上方下穿MA时,产生卖出信号。
|
|
|
|
4. 可以设置仅在特定月份的特定日期段交易。
|
|
|
|
5. 每次仅持有单向仓位,不做反向开仓。
|
|
|
|
6. 规则简单清晰,易于实施。
|
|
|
|
## 优势分析
|
|
|
|
1. EMA和MA交叉易于捕捉趋势反转机会。
|
|
|
|
2. 设置日期过滤,可以避开重大事件造成的失误交易。
|
|
|
|
3. 仅做单向仓位,可以减少无谓的反向开平仓。
|
|
|
|
4. 资金利用效率较高。
|
|
|
|
5. 适合短线趋势交易。
|
|
|
|
## 风险分析
|
|
|
|
1. 均线交叉可能出现假信号,导致不必要的亏损。
|
|
|
|
2. 无法有效控制单笔亏损的大小。
|
|
|
|
3. 无止损策略,存在更大的资金亏损风险。
|
|
|
|
4. 日期设置过于死板,可能错失交易机会。
|
|
|
|
5. 参数设置不当也会影响策略表现。
|
|
|
|
## 优化方向
|
|
|
|
1. 测试不同均线周期,寻找最优参数。
|
|
|
|
2. 评估交叉时需增加其他过滤条件。
|
|
|
|
3. 建立止损机制,控制单笔损失。
|
|
|
|
4. 优化日期过滤规则,保持一定灵活性。
|
|
|
|
5. 研究如何设置合理的止盈位置。
|
|
|
|
6. 考虑采用动态仓位管理策略。
|
|
|
|
## 总结
|
|
|
|
该策略基于EMA和MA均线交叉进行趋势反转交易,简单高效,但存在一些改进空间。通过参数优化、风险控制等手段进一步完善,可以将其打造成一个稳定的短线交易系统。
|
|
|
|
||
|
|
|
|
|
|
## Overview
|
|
|
|
This strategy uses EMA and MA crossover to determine trend reversals, belonging to typical trend following strategies.
|
|
|
|
## Strategy Logic
|
|
|
|
1. Calculate EMA and MA with specified periods respectively.
|
|
|
|
2. EMA crossover above MA generates buy signals.
|
|
|
|
3. EMA crossover below MA generates sell signals.
|
|
|
|
4. Can set trading only in specific months and date ranges.
|
|
|
|
5. Hold only one direction at a time, no reverse openings.
|
|
|
|
6. Simple and clear rules easy to implement.
|
|
|
|
## Advantages
|
|
|
|
1. EMA and MA crossovers can capture trend reversal opportunities.
|
|
|
|
2. Date filter avoids erroneous trades around major events.
|
|
|
|
3. Holding one direction reduces unnecessary reverse trades.
|
|
|
|
4. Higher capital usage efficiency.
|
|
|
|
5. Suitable for short-term trend trading.
|
|
|
|
## Risks
|
|
|
|
1. Crossovers may have false signals causing unnecessary losses.
|
|
|
|
2. No effective control over loss size per trade.
|
|
|
|
3. Larger loss risks without a stop loss.
|
|
|
|
4. Rigid date settings may miss trading opportunities.
|
|
|
|
5. Inappropriate parameters negatively affect performance.
|
|
|
|
## Enhancement
|
|
|
|
1. Test different MA periods to find optimal values.
|
|
|
|
2. Evaluate additional filters on crossovers.
|
|
|
|
3. Incorporate stop loss to control loss per trade.
|
|
|
|
4. Optimize date filter rules to maintain flexibility.
|
|
|
|
5. Research proper take profit positioning.
|
|
|
|
6. Consider dynamic position sizing.
|
|
|
|
## Conclusion
|
|
|
|
This strategy trades EMA and MA crossover reversals simply and efficiently but has some room for improvement. Further refinements like parameter optimization and risk controls can turn it into a steady short-term system.
|
|
|
|
[/trans]
|
|
|
|
> Strategy Arguments
|
|
|
|
|
|
|
|
|Argument|Default|Description|
|
|
|----|----|----|
|
|
|v_input_1|34|emaLength|
|
|
|v_input_2|89|maLength|
|
|
|v_input_3|8|monthfrom|
|
|
|v_input_4|12|monthuntil|
|
|
|v_input_5|true|dayfrom|
|
|
|v_input_6|31|dayuntil|
|
|
|
|
|
|
> Source (PineScript)
|
|
|
|
``` pinescript
|
|
//@version=2
|
|
strategy(title = "MA + EMA Crossover Strategy ",shorttitle="eMA", overlay = true,default_qty_type = strategy.percent_of_equity, default_qty_value = 100,commission_type=strategy.commission.percent,commission_value=0.1,initial_capital=100000)
|
|
|
|
|
|
emaLength =input(34)
|
|
|
|
maLength = input(89)
|
|
|
|
ema=ema(close,emaLength)
|
|
ma=sma(close,maLength)
|
|
|
|
plot(ema,linewidth=3,color=green)
|
|
plot(ma,linewidth=3,color=red)
|
|
longCond= crossover(ema,ma)
|
|
shortCond=crossover(ma,ema)
|
|
|
|
|
|
|
|
|
|
|
|
monthfrom =input(8)
|
|
monthuntil =input(12)
|
|
dayfrom=input(1)
|
|
dayuntil=input(31)
|
|
|
|
|
|
|
|
if ( longCond and month>=monthfrom and month <=monthuntil and dayofmonth>=dayfrom and dayofmonth < dayuntil)
|
|
strategy.entry("LONG", strategy.long, stop=close, oca_name="TREND", comment="LONG")
|
|
|
|
else
|
|
strategy.cancel(id="LONG")
|
|
|
|
|
|
|
|
|
|
if ( shortCond and month>=monthfrom and month <=monthuntil and dayofmonth>=dayfrom and dayofmonth < dayuntil )
|
|
|
|
strategy.entry("SHORT", strategy.short,stop=close, oca_name="TREND", comment="SHORT")
|
|
else
|
|
strategy.cancel(id="SHORT")
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
> Detail
|
|
|
|
https://www.fmz.com/strategy/427393
|
|
|
|
> Last Modified
|
|
|
|
2023-09-20 16:54:46
|