이동평균선을 교차하기 위한 Larry Williams 전략


생성 날짜: 2023-12-26 15:03:16 마지막으로 수정됨: 2023-12-26 15:03:16
복사: 1 클릭수: 1523
avatar of ChaoZhang ChaoZhang
1
집중하다
1623
수행원

이동평균선을 교차하기 위한 Larry Williams 전략

개요

이 전략은 유명한 트레이더인 레리 윌리엄스가 만든 간단한 고전적인 이동 평균을 가로질러 가는 전략이다. 이 전략은 9일 간단한 이동 평균을 빠른 라인으로, 21일 지수 이동 평균을 느린 라인으로 사용한다. 가격이 상승하면 9일 라인을 돌파하고, 가격이 하락하면 9일 라인을 돌파할 때 공백을 한다. 가짜 돌파를 필터링하기 위해 21일 라인 보조 판단 트렌드를 도입한다.

전략 원칙

이 전략은 이동 평균의 황금 교차와 죽음의 교차를 기반으로 장점과 적폐의 기회를 판단한다. 빠른 선이 아래에서 느린 선을 통과 할 때 금으로 교차하면, 거래가 불어나는 것을 나타냅니다. 이러한 돌파는 장점이다. 빠른 선이 위에서 아래로 긴 선을 통과 할 때 사망으로 교차하면, 거래가 하락하는 것을 나타냅니다.

가상 손실로 이어지는 가짜 브레이크를 피하기 위해, 전략은 21 일선 판단 큰 경향을 도입한다. 빠른 라인과 동시에 가격이 21 일선을 돌파 할 때만 거래 조치를 취한다. 이것은 많은 가짜 브레이크를 효과적으로 필터링 할 수 있습니다.

구체적으로 말하면, 더 많은 신호는: 빠른 선이 어제의 고점을 돌파하고, 동시에 빠른 선이 21 일선을 돌파하여 다면이 확립됩니다. 빈 신호는: 빠른 선이 어제의 낮은 점을 돌파하고, 동시에 빠른 선이 21 일선을 돌파하여 공백이 확립됩니다.

우위 분석

이 전략의 장점은 다음과 같습니다.

  1. 전략은 간단하고 이해하기 쉽고 실행이 가능합니다.
  2. 이동 평균 기술은 성숙해져 있고, 널리 사용되고 있다.
  3. 21 일선에서 가짜 돌파구를 효과적으로 필터링한다.
  4. 어제의 극한점으로 진입하면 을 피할 수 있다.
  5. 전략적 매개 변수는 안정적이고, 너무 잘 맞지 않습니다.

위험 분석

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

  1. 상황이 급격하게 변동할 때, 이동 평균은 지연되어 최고의 진출 포인트를 놓칠 수 있다.
  2. 하지만, 이 모든 것은, 이 모든 것은, 이 모든 것은, 이 모든 것은, 이 모든 것은, 이 모든 것은, 이 모든 것은.
  3. 급격한 사건으로 인한 중대한 상황 변화에 효과적으로 대처할 수 없습니다.

위와 같은 위험은 다음과 같은 방법으로 최적화 및 통제할 수 있습니다.

  1. MACD 지표 보조 판단을 도입하여 더 많은 실시간 신호를 얻을 수 있습니다.
  2. 이동 평균 주기 변수를 높여 거래 빈도를 낮추십시오.
  3. 단편적 손실을 통제하기 위한 손실을 막는 전략을 강화한다.

최적화 방향

이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.

  1. 매개 변수 최적화. MA 주기 매개 변수 조합을 더 체계적인 방법으로 테스트하여 더 우수한 매개 변수를 찾을 수 있다.

  2. 손실을 증가 합리적인 이동 손실, 축소 손실 등의 방법을 설정하여 단편 손실을 효과적으로 제어

  3. 다른 지표와 결합하여. MACD, ATR, KD와 같은 다른 지표 신호를 도입하여 더 많은 차원의 확인을 얻고 전략의 안정성을 향상시킵니다.

  4. 출장 메커니즘을 최적화한다. 출장 전략을 연구한다.

요약하다

이동 평균을 가로지르는 전략은 전반적으로 매우 전형적이고 실용적인 트렌드 추적 전략이다. 그것은 이해하기 쉽고 구현할 수 있는 장점이 있지만, 또한 개선할 여지가 있다. 매개 변수 최적화, 스톱 로즈 최적화, 다중 지표 결합과 같은 방법을 통해 이 전략에 지속적인 개선이 이루어져 더욱 안정적이고 실용적인 거래 시스템으로 만들 수 있다.

전략 소스 코드
// @_benac
//@version=5
strategy('Larry', overlay=true , initial_capital=1000 )


////////////////////////////////////////////////////////
//                                                    //
//                                                    //
//                 Codigo Operacional                 //
//                                                    //
//                                                    //
////////////////////////////////////////////////////////

// Usage for Stocks , or Criptos with value bigger then 1, cuz of 0.01 ´pip.
// Daily timeframe
//Observation Point
start     = timestamp(2020, 00, 00, 00, 00)         // backtest start window
finish    = timestamp(2022, 01, 07, 23, 59)        // backtest finish window
window()  => true // create function "within window of time"  

if time < start 
    strategy.close_all("Closing All")

// Take infos from inputs. 
inp_mmshort = input.int(defval = 9, title = "Media Curta"  )
inp_mminter = input.int(defval = 21, title = "Media Curta"  )

// Risk Manager, here define max and min 
inp_max = input.int(defval = 15, title = "Percentual Ganho"  )
inp_min = input.int(defval = 5, title = "Percental  Perda"  )

// Converting the input to % 
pmax = (inp_max / 100 )
pmin =  (inp_min / 100)

// Infos From Moving Average
mm_short = ta.sma(close , inp_mmshort)
mm_inter = ta.ema(close , inp_mminter)


// Trend Logic
//Long Condition 

//Setup do Larry Willians Bem Simples , media virou para cima e rompeu a maxima de referencia, compra. 
tendencia_alta = mm_short[2] > mm_short[1] and mm_short > mm_short[1] and close > high[1] and close > mm_short and mm_short > mm_inter
tendencia_baixa = mm_short[2] < mm_short[1] and mm_short < mm_short[1] and close > low[1] and close < mm_short and mm_short < mm_inter

// Creating the entry
if tendencia_alta 
    strategy.entry("Compra" , strategy.long , stop = low - 0.01  )
    stop_inst = low - 0.01 
if tendencia_baixa 
    strategy.entry("Venda" , strategy.short , stop= high + 0.01  )
    stop_inst = high + 0.01


// TrailingStop Creation

// Sell Position
if strategy.position_size < 0 
    gain_p = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * pmax) 
    stop_p = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * pmin) 
    // Managing the position
    if close < gain_p 
        strategy.close_all(comment = " 1 - Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )
    if close > stop_p 
        strategy.close_all(comment = " 2 - Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )
    
    if  high > mm_short[1]
        strategy.close_all(comment = " 3 - Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )
      

// Buy Position    
if strategy.position_size > 0
    gain_p = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * pmax) 
    stop_p = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * pmin) 
    // Managing the position
    if close > gain_p 
        strategy.close_all(comment = " 1- Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )
    if close < stop_p 
        strategy.close_all(comment = " 2 -Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )
    if low < mm_short[1]
        strategy.close_all(comment = " 3 -Ganho : " + str.tostring( gain_p) + " Perda : " + str.tostring( stop_p)  )