
이 전략은 유명한 트레이더인 레리 윌리엄스가 만든 간단한 고전적인 이동 평균을 가로질러 가는 전략이다. 이 전략은 9일 간단한 이동 평균을 빠른 라인으로, 21일 지수 이동 평균을 느린 라인으로 사용한다. 가격이 상승하면 9일 라인을 돌파하고, 가격이 하락하면 9일 라인을 돌파할 때 공백을 한다. 가짜 돌파를 필터링하기 위해 21일 라인 보조 판단 트렌드를 도입한다.
이 전략은 이동 평균의 황금 교차와 죽음의 교차를 기반으로 장점과 적폐의 기회를 판단한다. 빠른 선이 아래에서 느린 선을 통과 할 때 금으로 교차하면, 거래가 불어나는 것을 나타냅니다. 이러한 돌파는 장점이다. 빠른 선이 위에서 아래로 긴 선을 통과 할 때 사망으로 교차하면, 거래가 하락하는 것을 나타냅니다.
가상 손실로 이어지는 가짜 브레이크를 피하기 위해, 전략은 21 일선 판단 큰 경향을 도입한다. 빠른 라인과 동시에 가격이 21 일선을 돌파 할 때만 거래 조치를 취한다. 이것은 많은 가짜 브레이크를 효과적으로 필터링 할 수 있습니다.
구체적으로 말하면, 더 많은 신호는: 빠른 선이 어제의 고점을 돌파하고, 동시에 빠른 선이 21 일선을 돌파하여 다면이 확립됩니다. 빈 신호는: 빠른 선이 어제의 낮은 점을 돌파하고, 동시에 빠른 선이 21 일선을 돌파하여 공백이 확립됩니다.
이 전략의 장점은 다음과 같습니다.
이 전략에는 다음과 같은 위험들이 있습니다.
위와 같은 위험은 다음과 같은 방법으로 최적화 및 통제할 수 있습니다.
이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.
매개 변수 최적화. MA 주기 매개 변수 조합을 더 체계적인 방법으로 테스트하여 더 우수한 매개 변수를 찾을 수 있다.
손실을 증가 합리적인 이동 손실, 축소 손실 등의 방법을 설정하여 단편 손실을 효과적으로 제어
다른 지표와 결합하여. MACD, ATR, KD와 같은 다른 지표 신호를 도입하여 더 많은 차원의 확인을 얻고 전략의 안정성을 향상시킵니다.
출장 메커니즘을 최적화한다. 출장 전략을 연구한다.
이동 평균을 가로지르는 전략은 전반적으로 매우 전형적이고 실용적인 트렌드 추적 전략이다. 그것은 이해하기 쉽고 구현할 수 있는 장점이 있지만, 또한 개선할 여지가 있다. 매개 변수 최적화, 스톱 로즈 최적화, 다중 지표 결합과 같은 방법을 통해 이 전략에 지속적인 개선이 이루어져 더욱 안정적이고 실용적인 거래 시스템으로 만들 수 있다.
// @_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) )