골든 크로스 이동 평균 거래 전략

저자:차오장, 날짜: 2023-12-11 11:37:36
태그:

img

전반적인 설명

골든 크로스 이동 평균 거래 전략 (Golden Cross Moving Average Trading Strategy) 은 고전적인 양적 거래 전략이다. 이 전략은 장기 및 단위 포지션의 시장 트렌드를 결정하기 위해 다양한 기간의 이동 평균을 사용합니다. 단기 이동 평균이 장기 이동 평균보다 높을 때 구매 신호로 간주됩니다. 단기 이동 평균이 장기 이동 평균보다 낮을 때 판매 신호로 간주됩니다.

전략 논리

이 전략은 다른 기간의 세 가지 간단한 이동 평균 (SMA) 을 기반으로합니다: 50 일, 100 일 및 200 일. 구체적인 거래 논리는 다음과 같습니다.

  1. 엔트리 신호: 50일 이동 평균이 100일 이동 평균을 넘을 때, 장기화합니다.

  2. 출구 신호: 50일 이동 평균이 100일 이동 평균보다 낮을 때, 포지션을 닫습니다. 또는 닫기 가격이 100일 이동 평균보다 낮을 때, 출구; 또는 100일 이동 평균이 200일 이동 평균보다 낮을 때, 출구.

  3. 수익을 취하고 손실을 중지합니다: 수익을 취하고 손실을 중지합니다.

이 전략은 시장 평균 가격 추세를 효과적으로 결정하기 위해 이동 평균의 능력을 활용합니다. 단기 및 장기 평균의 교차는 시장이 상승 또는 하락 추세로 진입하는 것으로 간주되며, 따라서 긴 또는 출구 신호가 발생합니다. 이것은 전략이 시장 추세를 효과적으로 파악 할 수있게합니다.

장점

  1. 간단하게 구현할 수 있습니다. 다른 기간의 3개의 이동 평균만 필요합니다.

  2. 매우 안정적입니다. 이동 평균은 시장의 무작위성의 영향을 줄이고 신호를 더 신뢰할 수 있도록 하는 노이즈 필터링 능력을 가지고 있습니다.

  3. 주요 트렌드를 쉽게 파악할 수 있습니다. 이동 평균은 주요 트렌드 변화를 결정하기 위해 단기 및 장기 라인 간의 교차를 사용하여 평균 시장 가격 트렌드의 변화를 효과적으로 반영합니다.

  4. 매우 사용자 정의 가능. 이동 평균 기간은 위험 통제의 다른 수준을 조정 할 수 있습니다.

위험성

  1. 많은 잘못된 신호를 생성 할 수 있습니다. 단기 및 장기 평균이 너무 가까워지면 빈번한 교차가 발생할 수 있으며 과도한 유효하지 않은 신호가 발생합니다.

  2. 갑작스러운 이벤트에 반응하는 것이 느립니다. 이동 평균은 가격 변화에 느리게 반응하고 시장 뉴스 및 주요 이벤트에 즉각적으로 반응할 수 없습니다.

  3. 소액의 변동에서 이익을 얻을 수 없습니다. 소음 필터링은 또한 시장의 소액 변동에서 이익을 잃는 것을 의미합니다.

  4. 주관적 매개 변수 선택: 적절한 이동 평균 기간은 크게 주관적이며 특정 시장에 의존합니다.

더 나은 기회

  1. 잘못된 신호를 줄이기 위해 필터를 추가합니다. 예를 들어 가격 범위 필터와 같이 특정 크기의 움직임에 신호를 제한합니다.

  2. 신호 정확성을 향상시킬 수 있는 다른 지표, 예를 들어 변동성 또는 부피 지표를 결합 전략에 포함합니다.

  3. 기계 학습 알고리즘을 기반으로 움직이는 평균 기간을 동적으로 최적화하기 위해 적응 최적화 모듈을 추가하여 변화하는 시장 조건에 적응 할 수 있습니다.

  4. 고급 딥 러닝 모델을 적용하고 이동평균을 사용해서 우수한 특징 추출과 모델링을 할 수 있습니다.

결론

골든 크로스 이동 평균 거래 전략은 전형적인 트렌드 다음 전략이다. 그것은 초보자에게 적합한 단순하고 실용적인 평균 시장 가격 추세를 반영합니다. 그러나 다른 기술적 지표와 결합하여 신호 품질을 향상시키고 적응 메커니즘 등을 도입하여 개선 할 수있는 몇 가지 결함이 있습니다. 전반적으로 이것은 더 복잡한 시장에 적응하기 위해 높은 참조 및 학습 가치가있는 전략입니다.


/*backtest
start: 2023-12-03 00:00:00
end: 2023-12-10 00:00:00
period: 1m
basePeriod: 1m
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/
// © CJDeegan

//@version=4
strategy(title = "[LIVE] Golden Cross", overlay=true)

// ------------Functions------------

//Percent to Decimal Conversion
perToDec(a) => a * 0.01
//Price Difference to Tick
diffToTick(a,b) => (a - b) / syminfo.mintick 

    
// ------------Strategy Inputs------------
takeProfitInput = input(300, "Take Profit Price (% Gain)")
stopLossInput = input(25, "Stop Loss (% Loss)")


startDate = input(title="Start Date", type=input.integer,
     defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer,
     defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer,
     defval=2018, minval=1800, maxval=2100)

endDate = input(title="End Date", type=input.integer,
     defval=1, minval=1, maxval=31)
endMonth = input(title="End Month", type=input.integer,
     defval=1, minval=1, maxval=12)
endYear = input(title="End Year", type=input.integer,
     defval=2031, minval=1800, maxval=2100)

inDateRange = (time >= timestamp(syminfo.timezone, startYear,
         startMonth, startDate, 0, 0)) and
     (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
     

// ------------Populate Indicators------------

//EMA
sma50 = sma(close,50)
sma100 = sma(close,100)
sma200 = sma(close,200)


// ------------Entry Logic------------
//Guards
entryGuard = true
//Triggers
entryTrigger = crossover(sma50,sma100)
//Conditions
entryCondition = entryGuard and entryTrigger
//Calculations
//Execution
if (inDateRange and entryCondition)
    strategy.entry("Long", strategy.long, when = entryCondition, comment = "Entry")

//------------Exit Logic------------

//Guards
//Triggers
exitTrigger = crossunder(sma50,sma100) or close < sma100 or crossunder(sma100,sma200)
//Conditions
exitCondition = exitTrigger

//Calculations
//Take Profit
takeProfitPrice = strategy.position_avg_price + (strategy.position_avg_price * perToDec(takeProfitInput))
//Take Profit Ticks
takeProfitTicks = diffToTick(takeProfitPrice, strategy.position_avg_price)
//StopLoss
stopLossPrice = strategy.position_avg_price - (strategy.position_avg_price * perToDec(stopLossInput))

//Execution
if (inDateRange)
    strategy.close("Long", when = exitCondition, comment = "Sell Trigger")
    strategy.exit("Exit", "Long", comment="Stop", profit=takeProfitTicks, stop=stopLossPrice)

//Plots
plot(sma50, "SMA 50", color = color.blue)
plot(sma100, "SMA 100", color = color.green)
plot(sma200, "SMA 200", color = color.yellow)
entry = plot(strategy.position_size <= 0 ? na : strategy.position_avg_price, "Entry Price", color = color.yellow, style = plot.style_linebr)
profit = plot(strategy.position_size <= 0 ? na : takeProfitPrice, "Take Profit (Price)", color = color.green, style = plot.style_linebr)
stop = plot(strategy.position_size <= 0 ? na : stopLossPrice, "Stop Loss", color = color.red, style = plot.style_linebr)
fill(entry,profit, color=color.green)
fill(entry,stop, color=color.red)


더 많은