SMA和EMA双均线交易系统

时间:2024-03-03 09:46:00

最朴素的市场规律:价格,围绕市场平均成本上下波动。
两种算法:简单移动平均(SMA)、指数移动平均(EMA)。
过于确切的值对我们其实没有意义,精确的错误不如模糊的正确。

简单移动平均(SMA)

\(T\) 代表今天的收盘价, \(T^{\'}\) 代表明天的收盘价,\(T_1\) 代表昨天的收盘价,\(T_2\) 代表前天的收盘价,\(T_3, T_4, T_5 ...\)同理

\[MA_5(T)=\left\{ \begin{aligned} \frac{T_1 + T_2 + T_3 + T_4 + T_5}{5} & & (Yesterday)\\ \frac{T + T_1 + T_2 + T_3 + T_4}{5} & & (Today)\\ \frac{T^{\'} + T + T_1 + T_2 + T_3}{5} & & (Tomorrow) \end{aligned} \right. \]

要让 \((Today) > (Yesterday)\) ,也就是让今天的\(MA_5\)均线往上走,就是让 \(\frac{T + T_1 + T_2 + T_3 + T_4}{5} > \frac{T_1 + T_2 + T_3 + T_4 + T_5}{5}\) 。得:\(T > T_5\)
也就是说,如果今天的收盘价大于\(5\)天前的收盘价,则\(MA_5\)均线会在今天往上走。
要让 \((Tomorrow) > (Today)\) ,也就是让明天的\(MA_5\)均线往上走,就是让 \(\frac{T^{\'} + T + T_1 + T_2 + T_3}{5} > \frac{T + T_1 + T_2 + T_3 + T_4}{5}\) 。得:\(T^{\'} > T_4\)
也就是说,如果明天的收盘价大于4天前的收盘价,则\(MA_5\)均线会在明天往上走。
如果让 \(MA_a\) 代表 \(a\) 日移动平均线,可以得到一个一般性的结论:

  • \(a\) 日移动平均线要想在今天拐头向上,则今天的收盘价需要大于 \(a\) 天前的收盘价。
  • \(a\) 日移动平均线要想在明天拐头向上,则明天的收盘价需要大于 \(a-1\) 天前的收盘价。
  • 以此类推。

指数移动平均(EMA)

当前价格权重最大。
算法比较复杂,直接说结论:

  • 价(收盘价)在线(EMA均线)上,线向上。
  • 价在线下,线向下。

双线系统

相互印证,相互辅助。帮助我们判断趋势转折的重要线索。
EMA 比较敏感,MA 比较迟钝,在底部先拐头的一定是 EMA。在保证 EMA 均线稳定运行的前提下,引导 MA 均线拐头。这恰好是两次操作机会。
设定 20 60 120 双均线系统。

双均线 + 抵扣价指标(TradingView)

//@version=4
study("MA+EMA", overlay = true)
e1 = ema(close, 20)
c1 = sma(close, 20)
e2 = ema(close, 60)
c2 = sma(close, 60)
e3 = ema(close, 120)
c3 = sma(close, 120)

plot(e1, "ema20", color = color.gray)
plot(c1, "ma20", color = #D3D3D3)
plot(e2, "ema60", color = color.red)
plot(c2, "ma60", color = #FDBCB4)
plot(e3, "ema120", color = color.blue)
plot(c3, "ma120", color = #ADD8E6)

//DKJ
cond = barstate.islast
moveBar = input(0)
x20 = input(20) + moveBar
x60 = input(60) + moveBar
x120 = input(120) + moveBar

plot(cond?low[20]:na, color = #FFC40C, linewidth = 5, offset = -x20, style = plot.style_circles, transp = 0)
plot(cond?low[60]:na, color = #FFC40C, linewidth = 5, offset = -x60, style = plot.style_circles, transp = 0)
plot(cond?low[120]:na, color = #FFC40C, linewidth = 5, offset = -x120, style = plot.style_circles, transp = 0)

原视频:
趋势交易 | SMA和EMA双均线交易系统 | Trend Trading | 2 Moving Averages Strategy