듀얼 이동 평균 교차 일일 거래 선물 전략


생성 날짜: 2023-11-15 16:48:02 마지막으로 수정됨: 2023-11-15 16:48:02
복사: 2 클릭수: 686
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

듀얼 이동 평균 교차 일일 거래 선물 전략

개요

이 전략은 양평선 교차의 원리를 적용하고, ATR 지표와 함께 중지 손실을 설정하고, 거래 시간 통제를 보조하여, 하루 거래 선물 계약에 적합한 전략을 설계합니다. 전략은 간단하고 명확하며, 이해하기 쉽고, 초보자 사용에 적합합니다.

전략 원칙

이 전략은 5주기 및 20주기 WMA 평균선 교차를 입문 신호로 사용합니다. 5주기 라인이 하향에서 20주기 라인을 돌파 할 때, 더 많은 것을하십시오. 5주기 라인이 상향에서 20주기 라인을 넘어갈 때, 공백을하십시오.

또한, 전략은 ATR 지표를 사용하여 중지 손실을 설정한다. ATR 지표는 동적으로 시장의 변동량을 반영한다. 전략은 ATR 지표의 수치를 한 배로 (예: 3 배) 곱하여 중지 손실을 설정하여 단기 손실을 제어한다.

마지막으로, 전략은 미국 거래 시간 (9:00-14:30 CST) 에서만 거래 신호를 트리거한다. 이것은 상장과 상장 시간대에 거래하는 것을 피한다. 왜냐하면 이 두 시간대는 큰 변동이 있어 가짜 신호가 형성되기 쉽기 때문이다.

우위 분석

이 전략은 다음과 같은 장점을 가지고 있습니다.

  1. 쌍평선 교차를 사용하면 트렌드 전환점을 효과적으로 포착하고 적시에 진입할 수 있다.

  2. 큰 추세를 판단하여 일부 노이즈 트레이딩 신호를 필터링하여 역동적인 동작을 피하십시오.

  3. ATR 지표를 적용하여 스톱 로즈 위치를 동적으로 조정하여 단일 손실을 효과적으로 제어한다.

  4. 거래시간을 제한하고, 시장 개시와 종결시의 급격한 변동을 피하십시오.

  5. 전략 규칙은 간단하고 명확하며, 이해하기 쉽고 구현하기 쉬우며, 초보자도 익힐 수 있습니다.

  6. 평균선 주기, ATR 배수, 거래 시간 등 사용자 정의 가능한 매개 변수, 최적화 전략.

위험 분석

이 전략에는 다음과 같은 위험도 있습니다.

  1. 지진이 발생했을 때, 더 많은 피해가 발생할 수 있습니다.

  2. 쌍평선 교차는 약간의 지연이 있을 것이고, 짧은 선의 돌파를 놓칠 수도 있다.

  3. ATR 파라미터를 잘못 설정하면 너무 큰 또는 너무 작은 정지 손실이 발생할 수 있습니다.

  4. 기술적인 지표에만 의존하고 기본적인 정보를 무시하는 것.

  5. 거래 유형과 주기적 부적합성은 전략의 효과에 영향을 미칩니다.

  6. 기계 거래 시스템은 중도 거래의 위험이 있습니다.

  7. 다른 거래 시기의 파라미터는 조정해야 합니다.

이것은 변수 최적화, 지표 조합, 적절한 인적 개입 등의 방법으로 개선되어야 합니다.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.

  1. EMA, DMA 등과 같은 다른 일률적인 시스템을 시도하십시오.

  2. MACD, RSI 등과 같은 다른 기술 지표 필터를 추가하십시오.

  3. ATR 파라미터를 최적화하여 스톱더스트를 더 합리적으로 만듭니다.

  4. 거래량 지표와 함께 효율적인 입시점을 찾아보세요.

  5. 다양한 품종의 특성에 따라 파라미터를 조정한다.

  6. 기본적 요소와 결합하여 반시장 조작을 피하십시오.

  7. 기계 학습 요소를 추가하고, 뉴럴 네트워크를 사용하여 데이터를 모델링한다.

  8. 이 프로젝트의 핵심은, “일반적으로, 우리는 더 많은 기회를 얻을 수 있습니다.

  9. 전략 포트폴리오를 구축하고 안정성을 높여라.

요약하다

이 전략은 전반적으로 단순하고 일반적이며 초보자 실무 연습에 적합하다. 동시에 많은 최적화 공간이 남아 있으며, 더 많은 기술 지표 또는 기계 학습 방법을 도입하여 개선 할 수 있습니다. 또한, 다른 거래 품종 특성과 시장 환경에 따라 변수를 조정하는 것도 중요합니다. 요컨대, 이 전략은 양적 거래 초보자에게 참조 프레임워크를 제공하지만 실제 상황에 따라 지속적인 테스트와 최적화를 통해 안정적인 수익을 얻을 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 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/
// © james4392010

//@version=4

strategy(title="DayTradingFutures Cross-Strategy", overlay=true)




// === GENERAL INPUTS ===
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
//highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn



wmaFastSource   = input(defval = close, title = "Fast WMA Source")
wmaFastLength   = input(defval = 5, title = "Fast WMA Period")
wmaSlowSource   = input(defval = close, title = "Slow WMA Source")
wmaSlowLength   = input(defval = 20, title = "Slow WMA Period")
wmaDirectionSource  = input(defval = close, title = "Trend 50 Period Source")
wmaDirectionLength  = input(defval = 50, title = "Trend 50 Period")
timeinrange(res, sess) => time(res, sess) != 0



// === SERIES SETUP ===
/// a couple of ma's..
wmaFast = wma(close, 5)
wmaSlow = wma(close, 20)
wmaDirection = wma(close, 50)





// === PLOTTING ===
fast = plot(series=wmaFast, color=color.white, linewidth=2)
slow = plot(series=wmaSlow, color=color.yellow, linewidth=2)
direction = plot(series=wmaDirection, color=color.red, linewidth=2)


// === INPUT BACKTEST RANGE ===

//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 = 2022, title = "From Year", minval = 2022)
 
// To Date Inputs
//toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
//toMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
//toYear = input(defval = 2022, title = "To Year", minval = 2022)
//startDate = timestamp(fromYear, fromMonth, fromDay)
//finishDate = timestamp(toYear, toMonth, toDay)
//inDateRange= (time >= fromDay, fromMonth, fromYear and time <= toDay, toMonth, toYear) 



// === FUNCTION EXAMPLE ===
//inDateRange = (time >= fromDay, fromMonth, fromYear) and (time <= toDay, toMonth, toYear)


// === LOGIC ===

enterLong = crossover(wmaFast, wmaSlow) and close > wmaDirection and timeinrange(timeframe.period, "0900-1430")
enterShort = crossunder(wmaFast, wmaSlow) and close < wmaDirection and timeinrange(timeframe.period, "0900-1430")

//trend := nz(trend[1], trend)
//trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
//upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)

buySignal = enterLong 
//plotshape(enterLong ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green)
plotshape(enterLong and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)
//dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)

sellSignal = enterShort
//plotshape(enterShort ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red)
plotshape(enterShort and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
//mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
//longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
//shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
//fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
//fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="Buy", message="Buy!")
alertcondition(sellSignal, title="Sell", message="Sell!")
//changeCond = trend != trend[1]
//alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")



// Entry for strategy //

//tp=input(25,title="TakeProfit")
//sl=input(40,title="StopLoss")

strategy.entry("Long",1, when=buySignal)
//strategy.exit("Exit",profit=tp,loss=sl)
//strategy.exit("TakeProfit",profit=tp)
//strategy.exit("StopLoss",loss=sl)

strategy.entry("Short",1, when=sellSignal)
//strategy.exit("Exit",profit=tp,loss=sl)
//strategy.exit("TakeProfit",profit=tp)
//strategy.exit("StopLoss",loss=sl)
//strategy.exit("Exit", wmaFastwmaSlow)

//Buy and Sell Signals

//strategy.close_all(when =not timeinrange(timeframe.period, "1000-1430"))   


// === FILL ====

fill (fast, slow, color = wmaSlow > wmaDirection ? color.green : color.red)
//fill(when=enterLong, tp, color = color.new(color.green, 90), title = "Profit area")
//fill(when=enterLong, sl, color = color.new(color.red, 90), title = "Loss area")
//fill(when=enterShort, tp, color = color.new(color.green, 90), title = "Profit area")
//fill(when=enterShort, sl, color = color.new(color.red, 90), title = "Loss area")