MACD + SMA 200 전략

저자:차오장, 날짜: 2022-05-07 17:13:32
태그:MACD

여기서는 클래식 MACD (가동 평균 컨버전스 디버전스 지표) 와 클래식 느린 이동 평균 SMA의 조합이 있습니다. 기간 200을 함께 전략으로 사용합니다.

이 전략은 MACD 히스토그램과 MACD 모멘텀이 모두 0보다 높고 빠른 MACD 이동 평균이 느린 MACD 이동 평균보다 높으면 길어집니다. 추가 긴 필터로 최근 가격은 SMA 200보다 높아야합니다. 역 논리가 사실이라면 전략은 짧습니다. 최악의 경우 필터 50%의 최대 내일 주식 손실이 있습니다.

내 무료 전략으로 999달러 더 절약해

이 전략은 비트코인의 일일 차트, 그리고 S&P 500 및 도 존스 산업평균 일일 차트에서 백테스트에서 작동합니다. 2015년 11월 30일 기준 현재 SPX500 CFD 일일 수치는 수익률: 1970년 이후 68% 6.4의 수익률로. 2015년 11월 30일 기준 DOWI 지수 일일 수치는 수익률: 1915년 이후 51% 10.8의 수익률로.

모든 거래는 높은 위험을 포함합니다. 과거의 성과는 반드시 미래의 결과를 나타내는 것은 아닙니다. 가설적 또는 시뮬레이션 성과 결과는 특정 고유 한 제한을 가지고 있습니다. 실제 성과 기록과 달리 시뮬레이션 결과는 실제 거래를 대표하지 않습니다. 또한, 거래가 실제로 실행되지 않았기 때문에, 결과는 유동성 부족과 같은 특정 시장 요인의 영향을 과소 또는 과대 보상 할 수 있습니다. 일반적으로 시뮬레이션 거래 프로그램은 후견의 이익을 위해 설계되어 있다는 사실에도 종속됩니다. 어떤 계정도 표시 된 것과 유사한 이익이나 손실을 달성하거나 달성할 가능성이 있다고 표현되지 않습니다.

백테스트

img


/*backtest
start: 2021-05-06 00:00:00
end: 2022-05-05 23:59:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("MACD + SMA 200 Strategy (by ChartArt)", shorttitle="CA_-_MACD_SMA_strategy", overlay=true)

// ChartArt's MACD + SMA 200 Strategy
//
// Version 1.0
// Idea by ChartArt on November 30, 2015.
//
// Here is a combination of the MACD with the
// slow moving average SMA 200 as a strategy.
//
// This strategy goes long if the MACD histogram
// and the MACD momentum are both above zero and
// the fast MACD moving average is above the
// slow MACD moving average. As additional long filter
// the recent price has to be above the SMA 200.
// If the inverse logic is true, the strategy
// goes short. For the worst case there is a
// max intraday equity loss of 50% filter.


// Input
source = input(close)
fastLength = input(12, minval=1, title="MACD fast moving average")
slowLength=input(26,minval=1, title="MACD slow moving average")
signalLength=input(9,minval=1, title="MACD signal line moving average")
veryslowLength=input(200,minval=1, title="Very slow moving average")
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Moving Averages?")
switch3=input(true, title="Enable Background Color?")

// Calculation
fastMA = ta.sma(source, fastLength)
slowMA = ta.sma(source, slowLength)
veryslowMA = ta.sma(source, veryslowLength)
macd = fastMA - slowMA
signal = ta.sma(macd, signalLength)
hist = macd - signal

// Colors
MAtrendcolor = change(veryslowMA) > 0 ? color.green : color.red
trendcolor = fastMA > slowMA and change(veryslowMA) > 0 and close > slowMA ? color.green : fastMA < slowMA and change(veryslowMA) < 0 and close < slowMA ? color.red : color.blue
bartrendcolor = close > fastMA and close > slowMA and close > veryslowMA and change(slowMA) > 0 ? color.green : close < fastMA and close < slowMA and close < veryslowMA and change(slowMA) < 0 ? color.red : color.blue
backgroundcolor = slowMA > veryslowMA and crossover(hist, 0) and macd > 0 and fastMA > slowMA and close[slowLength] > veryslowMA ? color.green : slowMA < veryslowMA and crossunder(hist, 0) and macd < 0 and fastMA < slowMA and close[slowLength] < veryslowMA ? color.red : na
//bgcolor(switch3?backgroundcolor:na,transp=80)
//barcolor(switch1?bartrendcolor:na)

// Output
F=plot(switch2?fastMA:na,color=trendcolor)
S=plot(switch2?slowMA:na,color=trendcolor,linewidth=2)
V=plot(switch2?veryslowMA:na,color=MAtrendcolor,linewidth=4)
//fill(F,V,color=gray)

// Strategy
buyprice = low
sellprice = high
cancelLong = slowMA < veryslowMA
cancelShort = slowMA > veryslowMA


if crossover(hist, 0) and macd > 0 and fastMA > slowMA and close[slowLength] > veryslowMA 
    strategy.entry("MACDLE", strategy.long, stop=buyprice, comment="Bullish")

else if crossunder(hist, 0) and macd < 0 and fastMA < slowMA and close[slowLength] < veryslowMA 
    strategy.entry("MACDSE", strategy.short, stop=sellprice, comment="Bearish")

//maxIdLossPcnt = input(50, "Max Intraday Loss(%)", type=float)
//strategy.risk.max_intraday_loss(maxIdLossPcnt, strategy.percent_of_equity)

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

관련

더 많은