목성과 토성 모멘텀 MA 크로스오버 필터 전략

저자:차오장, 날짜: 2023-11-03 16:13:20
태그:

img

전반적인 설명

이 전략은 이동 평균 크로스오버를 거래 신호로 사용하며, 변동성 지표 BB와 필터링을 위한 사용자 지정 모멘텀 지표와 결합하여 MA 크로스오버 신호의 신뢰성을 향상시키고 잘못된 신호를 줄이도록 목표로 합니다.

원칙

  1. 50주기 EMA와 200주기 SMA를 사용하여 황금색 십자와 죽음의 십자 신호를 형성합니다.

  2. 가격이 상승 추세에 있을 때, 구매 신호를 생성하기 위해 가격이 200일 라인 이상이고 사용자 지정 모멘텀 지표 값이 25 이하가 되어야 합니다.

  3. 가격이 하락 추세에 있을 때, 판매 신호를 생성하기 위해 200일 라인 이하의 가격과 75 이상의 사용자 지정 모멘텀 지표 값을 요구합니다.

  4. 사용자 지정 모멘텀 지표는 BB 중간선과 대역 거리를 0-100 범위로 지도로 만듭니다.

  5. 모멘텀 인디케이터는 상대적인 가격 변동성을 반영하고, 임계 필터링은 잘못된 크로스오버를 줄이는 데 도움이됩니다.

장점

  1. 중장기 동향을 파악하기 위해 EMA와 SMA의 강점을 활용합니다.

  2. 모멘텀 지표로 필터레이션이 증가하면 신뢰성이 향상되고 잘못된 신호가 감소합니다.

  3. BB 대역 거리는 변동성 강도를 반영하고, 역사적 정상화는 매개 변수 의존성을 피합니다.

  4. 사용자 정의 가능한 EMA, SMA 기간 및 변화하는 시장 환경에 적응 가능한 모멘텀 임계.

  5. 최적화 유연성과 강력한 실용성을 가진 간단한 논리

위험 분석

  1. EMA와 SMA는 지연 효과를 가지고 있고, 단기 기회를 놓칠 수도 있습니다.

  2. 범위에 제한된 시장에 적합하지 않은 특성을 따르는 경향.

  3. 모멘텀 임계값은 최적의 매개 변수를 위해 반복적인 백테스팅을 필요로 합니다.

  4. 장기적인 시스템은 안정적이지만 잠재적으로 제한된 절대 수익을 제공합니다.

  5. MA 기간을 단축하거나 적응력을 향상시키기 위해 보완적 지표를 추가 할 수 있습니다.

더 나은 기회

  1. 최적의 매개 변수를 위해 다른 MA 조합을 테스트합니다.

  2. MACD, KD 같은 보완적 지표들을 추가 검증을 위해 추가합니다.

  3. 역행 기간, 매핑 범위와 같은 모멘텀 지표 매개 변수를 최적화합니다.

  4. 스톱 로스를 포함해서 리스크를 통제해야 합니다.

  5. 기계 학습 기능 추출을 사용하여 기호 특정 매개 변수를 조정합니다.

  6. 부득이한 크로스오버 신호를 피하기 위해 볼륨 표시기를 추가합니다.

결론

이 전략은 높은 신뢰성과 실용적 가치를 위해 장기 트렌드 추적 및 이중 추진력 임계 필터링의 장점을 결합합니다. 파라미터 최적화 및 보완 기술로 추가 개선이 가능합니다. 혁신적인 개념은 다른 트렌드 시스템에 대한 귀중한 통찰력을 제공합니다. 알고리즘 거래 전략 라이브러리에 귀중한 추가입니다.


/*backtest
start: 2023-10-26 00:00:00
end: 2023-10-27 13:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(title="EMA Difference Mapping with Trades", shorttitle="EMA Diff Map", overlay=false)

// Inputs
emaLength = input(20, "EMA Length")
stdDevLength = input(2, "Standard Deviation Length")
priceSource = close
takeProfitPoints = input(1000, title="Take Profit (in Points)")
stopLossPoints = input(2500, title="Stop Loss (in Points)")

// Calculate EMA
ema = ema(priceSource, emaLength)

// Calculate Standard Deviation
stdDev = stdev(priceSource, stdDevLength)

// Calculate differences
diff1 = (ema + stdDev) - ema
diff2 = ema - (ema - stdDev)

// Calculate min and max differences from last year
lookbackPeriod = 504 // Number of trading days in a year
minDiff1 = lowest(diff1, lookbackPeriod)
maxDiff1 = highest(diff1, lookbackPeriod)
minDiff2 = lowest(diff2, lookbackPeriod)
maxDiff2 = highest(diff2, lookbackPeriod)

// Map differences based on requirements
mappedDiff1 = 50 + 50 * ((diff1 - minDiff1) / (maxDiff1 - minDiff1))
mappedDiff2 = 50 - 50 * ((diff2 - minDiff2) / (maxDiff2 - minDiff2))

// Combine mapped differences into a single line
mappedLine = if close > ema
    mappedDiff1
else
    mappedDiff2

// Plot 'mappedLine' in the main chart area conditionally
plot(mappedLine, title="EMA Difference Mapping", color=(close > ema ? color.blue : na), style=plot.style_line, linewidth=2)

// Calculate the 50EMA and 200SMA
ema50 = ema(close, 50)
sma200 = sma(close, 200)

// Plot the 50EMA and 200SMA on the main chart
plot(ema50, color=color.blue, title="50 SMA", linewidth=2)
plot(sma200, color=color.red, title="200 SMA", linewidth=2)

// Initialize trade variables
var bool waitingForBuy = na
var bool waitingForSell = na
var bool buyConditionMet = false
var bool sellConditionMet = false

if not sellConditionMet and crossunder(ema50, sma200)
    sellConditionMet := true
    waitingForBuy := false

if sellConditionMet 
    waitingForSell := true
    sellConditionMet := false

if waitingForSell and close < sma200 and mappedLine > 75
    strategy.entry("Sell", strategy.short)
    strategy.exit("Sell Exit", "Sell", profit=takeProfitPoints, loss=stopLossPoints)
    waitingForSell := false

// Define the strategy conditions and execute trades
if not buyConditionMet  and crossover(ema50, sma200)
    buyConditionMet := true
    waitingForSell := false

if buyConditionMet 
    waitingForBuy := true
    buyConditionMet := false

if waitingForBuy and close > sma200 and mappedLine < 25
    strategy.entry("Buy", strategy.long)
    strategy.exit("Buy Exit", "Buy", profit=takeProfitPoints, loss=stopLossPoints)
    waitingForBuy := false


더 많은