탄탄한 이동 평균 시스템 전략

저자:차오장, 날짜: 2023-11-24 15:11:18
태그:

img

전반적인 설명

이 전략은 4개의 SMMA (Smoothed Moving Average) 를 기반으로 다양한 기간과 1개의 EMA 지표를 가진 이동 평균 시스템이다. 트렌드 판단을 통해 여러 기술적 분석 도구를 결합하여 거래 전략을 형성한다. 이 전략은 주로 고레버리지 EURUSD 15분 채권 내일 거래에 적합하다.

전략 원칙

이 전략은 다양한 매개 변수 (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)



더 많은