坚实稳健的移动平均系统策略


创建日期: 2023-11-24 15:11:18 最后修改: 2023-11-24 15:11:18
复制: 0 点击次数: 491
avatar of ChaoZhang ChaoZhang
1
关注
1364
关注者

坚实稳健的移动平均系统策略

概述

该策略是一个基于4个不同周期的SMMA(平滑移动平均线)以及1个EMA指标的移动平均系统。它结合了多个证券技术分析工具,通过趋势判断形成交易策略。该策略主要适用于高杠杆账户的EURUSD 15分钟债券进行日内交易。

策略原理

该策略使用4个不同参数的SMMA(3,6,9,50)以及1个EMA(200)构建多层次的移动平均系统。SMMA指标可以有效过滤市场噪音,判断趋势方向。EMA指标检测长期趋势。具体交易逻辑是:

当短周期移动平均线(例如3周期SMMA)上穿较长周期移动平均线(例如200周期EMA)时产生买入信号。当短周期移动平均线下穿较长周期移动平均线时产生卖出信号。这样通过判断多个移动平均线的排列关系确定趋势方向。

此外,策略还设定了止盈止损点以控制风险。

优势分析

该策略具有以下优势:

  1. 多层次移动平均线结构可以有效判断趋势方向,减少假信号。

  2. SMMA指标有效过滤了市场噪音,EMA指标检测长线趋势。

  3. 适合高杠杆账户,可以放大交易盈利。

  4. 设定了止盈止损点,可以有效控制风险。

  5. 优化了交易品种(EURUSD)和周期(15分钟),使其更具优势。

风险分析

该策略也存在以下风险:

  1. 大量使用移动平均线,可能错过短期反转机会。

  2. 高杠杆放大损失的同时也放大了盈利。

  3. 移动平均线产生信号时,短期行情可能已经发生反转。

  4. EURUSD汇率可能产生剧烈波动,带来更大风险。

针对这些风险,可以适当调整杠杆倍数,优化移动平均线的参数,引入其他指标判断行情反转等进行优化。

优化方向

该策略的主要优化方向有:

  1. 评估不同品种和周期的表现,选择最优参数。

  2. 测试不同的参数组合和数量的移动平均线。

  3. 增加成交量或波动率指标判断短期反转点。

  4. 增加止盈止损幅度的动态调整。

  5. 加入ENU指标判断反转点。

通过多方面测试和优化,可以大幅提高策略的稳定性和盈利能力。

总结

该移动平均线策略整合了均线指标的优势,形成稳健的趋势判断系统。它优化了交易品种和周期,非常适合高杠杆日内交易。通过参数调整和优化测试,该策略可以成为高效可靠的算法交易策略。

策略源码
/*backtest
start: 2023-10-24 00:00:00
end: 2023-11-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SoftKill21

//@version=4
strategy("Money maker EURUSD 15min" )
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2000, title = "From Year", minval = 1970)
 
// To Date Inputs
toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2021, title = "To Year", minval = 1970)
 


startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)




len = input(3, minval=1, title="Length")
src = input(hl2, title="Source")
smma = 0.0
sma1 = sma(src, len)
smma := na(smma[1]) ? sma1 : (smma[1] * (len - 1) + src) / len

len2 = input(6, minval=1, title="Length")
src2 = input(hl2, title="Source")
smma2 = 0.0
sma2 = sma(src2, len2)
smma2 := na(smma2[1]) ? sma2 : (smma2[1] * (len2 - 1) + src2) / len2

len3 = input(9, minval=1, title="Length")
src3 = input(hl2, title="Source")
smma3 = 0.0
sma3 = sma(src3, len3)
smma3 := na(smma3[1]) ? sma3 : (smma3[1] * (len3 - 1) + src3) / len3

len4 = input(50, minval=1, title="Length")
src4 = input(close, title="Source")
smma4 = 0.0
sma4 = sma(src4, len4)
smma4 := na(smma4[1]) ? sma4  : (smma4[1] * (len4 - 1) + src4) / len4

len5 = input(200, minval=1, title="Length")
src5 = input(close, title="Source")
out5 = ema(src5, len5)

timeinrange(res, sess) => time(res, sess) != 0
london=timeinrange(timeframe.period, "0300-1045")
londonEntry=timeinrange(timeframe.period, "0300-0845")

extraEntry =timeinrange(timeframe.period, "0745-1030")

time_cond = true
//time_cond2 = time >= startDate and time <= finishDate and extraEntry

//

longCond = close > out5 and close > smma4 and close > smma3 and close > smma2 and close > smma  and smma > smma2 and smma2>smma3 and smma3>smma4 and smma4>out5 and time_cond
shortCond = close < out5 and close < smma4 and close < smma3 and close < smma2 and close < smma  and smma < smma2 and smma2<smma3 and smma3<smma4 and smma4<out5 and time_cond


//longCond = close > out5 and close > smma4 and close > smma3 and close > smma2 and close > smma  and smma > smma2 and smma2>smma3 and smma3>smma4 and smma4>out5 and time_cond2
//shortCond = close < out5 and close < smma4 and close < smma3 and close < smma2 and close < smma  and smma < smma2 and smma2<smma3 and smma3<smma4 and smma4<out5 and time_cond2

//longCond2 = crossover(close,out5) and crossover(close,smma4) and crossover(close,smma3) and crossover(close,smma2) and crossover(close,smma) and time_cond
//shortCond2 = crossunder(close,out5) and crossunder(close,smma4) and crossunder(close,smma3) and crossunder(close,smma2) and crossunder(close,smma) and time_cond



tp=input(300,title="tp")
sl=input(300,title="sl")

strategy.initial_capital  = 50000

//MONEY MANAGEMENT--------------------------------------------------------------
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit          //floating profit/loss
risk = input(1,type=input.float,title="Risk %")/100           //risk % per trade


    //Calculate the size of the next trade
temp01 = balance * risk     //Risk in USD
temp02 = temp01/sl        //Risk in lots
temp03 = temp02*100000      //Convert to contracts
size = temp03 - temp03%1000 //Normalize to 1000s (Trade size)
if(size < 1000)
    size := 1000           //Set min. lot size

dataL = (close-out5)*100000
dataS = (out5-close)*100000

minDistanceL = (smma4 - out5)*100000
minDistanceS= (out5 - smma4)*100000


strategy.entry("long",1,1,when=longCond )
strategy.exit("closelong","long", profit=tp,loss=sl)
    
strategy.entry("short",0,1,when=shortCond )
strategy.exit("closeshort","short", profit=tp,loss=sl)



strategy.close_all(when = not london, comment="london finish")
//strategy.close_all(when = not extraEntry, comment="london finish")



// maxEntry=input(2,title="max entries")
// strategy.risk.max_intraday_filled_orders(maxEntry)