이중 이동 평균 추세 추종 전략


생성 날짜: 2023-09-24 13:14:08 마지막으로 수정됨: 2023-09-24 13:14:08
복사: 0 클릭수: 694
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 장기 RMA 평균선과 단기 EMA 평균선 조합을 사용하여 트렌드를 판단하고, 높은 낮은 지점의 돌파구를 통해 트렌드 추적 스톱로스를 구현한다. 또한 가짜 돌파구를 필터링하기 위해 거래없는 영역을 설정한다.

전략 원칙

  1. 장기기 RMA와 단기 EMA를 사용하여 트렌드 방향을 판단한다. 단기 EMA 아래에는 장기 RMA를 가시 신호로, 위에는 가시 다수 신호로 착용한다.

  2. 가격이 최근 특정 주기 최상위 가격을 돌파했을 때, 최고 가격을 추적하는 방법을 사용하여 중지한다. 가격이 최근 특정 주기 최저 가격을 돌파했을 때, 최저 가격을 추적하는 방법을 사용하여 중지한다.

  3. 거래 없는 구역을 설정하고, 가격이 그 구역에 들어가면 포지션이 열리지 않고, 피당하는 것을 피한다. 범주는 RMA 평균선에 의해 일정 비율로 결정된다.

  4. 입점 후 정지 가격을 설정하고, 일정 비율로 수익을 탈퇴한다.

전략적 이점

  1. 양평선 조합은 트렌드 방향을 정확하게 판단할 수 있다.

  2. 트래킹 스톱은 스톱을 트렌드에 따라 움직이게 합니다.

  3. 거래 없는 구역을 설정하여 가짜 브레이크 신호를 효과적으로 필터링한다.

  4. 정지 설정은 전략이 충분한 수익을 축적한 후에 적극적으로 청산하도록 합니다.

전략적 위험

  1. 이중평선에서 사각지대가 생성될 때 지연이 있을 수 있으며, 이로 인해 손실이 확대된다.

  2. 트래킹 스탠드포드 (Tracking Stop Loss Point) 가 가격에 너무 가깝다면, 초기 소음으로 인해 트래킹 스탠드포드가 깨질 수 있습니다.

  3. 거래 없는 구역을 너무 넓게 설정하면 거래 기회를 놓치게 됩니다.

  4. 적자를 제때 막지 못하면 손실이 더 커질 수 있습니다.

대응방법:

  1. 평균선 변수를 최적화하여 지연 확률을 줄인다.

  2. 너무 민감하지 않게 막기 위해 적절한 완화를 해야 합니다.

  3. 테스트는 거래되지 않는 영역의 범위를 조정하여 놓친 기회를 방지합니다.

  4. 다른 손해 방지 방법을 추가하여 최대 손실을 제한하십시오.

전략 최적화 방향

  1. 다른 평형 지표 조합을 테스트하여 더 잘 맞는 조합을 찾으십시오.

  2. 가격 격차, MACD와 같은 판단 지표를 증가시키고, 전략의 안정성을 향상시킵니다.

  3. 기계 학습 알고리즘 최적화 파라미터를 도입하여 전략을 더 지능화하십시오.

  4. 트렌드 강점과 약점 지표를 결합하여 역동적인 거래를 피하십시오.

  5. 자금 관리 전략을 최적화하고, 전략의 성공률을 높여라.

요약하다

이 전략은 양평선으로 트렌드 방향을 판단하고, 높은 낮은 지점을 추적하는 스톱 손실과 거래없는 구역 필터링으로 트렌드 수익을 잠금합니다. 전략의 프레임 워크는 간단하고 명확하며, 확장성이 강하며, 파라미터 범위를 조정하여 스톱 손실 전략을 최적화하고, 다른 보조 판단 지표 방법을 도입하여 최적화 할 수 있습니다. 전략은 다양한 시장에서 좋은 효과를 발휘 할 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-08-24 00:00:00
end: 2023-09-12 00:00:00
period: 3h
basePeriod: 15m
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/
// © PatrickGwynBuckley

//@version=5
//var initialCapital = strategy.equity

strategy("PB Trend Scalper", "PB Trend Scalper", overlay = true)
shortma = input.int(55, title="quick ma's")
longma = input.int(100, title="long ma's")
ema55h = ta.ema(high, shortma)
ema55l = ta.ema(low, shortma)
ema200h = ta.rma(high, longma)
ema200l = ta.rma(low, longma)
stock = ta.stoch(close, high, low, 14)

lev = input.int(3, title="leverage")
hhVal = input.int(170, title="Highest high period")
llVal = input.int(170, title="Lowest low period")

hh = ta.highest(high, hhVal)
ll = ta.lowest(low, llVal)
//plot(stock)

plot(hh, color=color.new(color.green, 50))
plot(ll, color=color.new(color.red, 50))
var float downtrade = 0
p = input.float(3.0, title="no trade zone")
l = 3
emadistlong = ema200h + ((ema200h/100)*p)
emadistshort = ema200l - ((ema200h/100)*p)

plot(ema55h)
plot(ema55l)
ntl = plot(emadistlong, color=color.new(color.red, 10))
nts = plot(emadistshort, color=color.new(color.red, 10))
fill(ntl, nts, color=color.new(color.red, 90))

//position size

EntryPrice = close
//positionValue = initialCapital
positionSize = (strategy.equity*lev) / EntryPrice

//plot(strategy.equity)


//standard short

if ema55h < ema200l and close[2] < ema55l and close[1] > ema55l and high[1] < ema55h and close < ema55h and ema55h < emadistshort and strategy.opentrades == 0// and stock > 85 
    strategy.entry("short", strategy.short, qty=positionSize, comment="short")
    downtrade := 1

//reset count    
if (ta.crossunder(ema55h, ema200l)) and downtrade == 1
    downtrade := 0

//standard long    
if ema55l > ema200h and close[2] > ema55h and close[1] < ema55h and low[1] > ema55l and close > ema55l and ema55l > emadistlong and strategy.opentrades <= 1// and stock < 15 
    strategy.entry("long", strategy.long, qty=positionSize, comment="long")
    downtrade := 0

//RESET COUNT ON MA CROSS
if (ta.crossover(ema55l, ema200h)) and downtrade == 0
    downtrade := 1
    
longclose2 = low < ll[1] or low < emadistshort //close < open and open<open[1] and open[2] < open[3] and open[3] < emadistshort//close < ta.lowest(low, 20)//
shortclose2 = high > hh[1] or high>emadistlong//close > open and open>open[1] and open[2]>open[3] and open[3] > emadistlong//high > emadistlong//close > ta.highest(high, 20)//

sl = 3.5
tp = input.float(6.9, title="take profit %")
tp2 = 10


strategy.exit("long exit", "long", profit = (strategy.position_avg_price*(tp)))//, loss = (strategy.position_avg_price*(sl)))
strategy.close("long", when = longclose2, comment = "long exit")
//strategy.close("long", when = (downtrade == 1), comment = "long exit")
//strategy.exit("long exit", "long2", profit = (strategy.position_avg_price*(tp2)))//, loss = (strategy.position_avg_price*(sl)))
//strategy.close ("long2", when = longclose2, comment = "long exit")
//strategy.close("long", when = (downtrade == 1), comment = "long exit")

strategy.exit("short exit", "short", profit = (strategy.position_avg_price*(tp)))//, loss = (strategy.position_avg_price*(sl)))//, loss = 300)
strategy.close("short", when = shortclose2, comment = "short exit")
//strategy.close("short", when = (downtrade == 0), comment = "short exit")
//strategy.exit("short exit", "short2", profit = (strategy.position_avg_price*(tp2)))//, loss = (strategy.position_avg_price*(sl)))
//strategy.close ("short2", when = shortclose2, comment = "short exit")
//strategy.close("short2", when = (downtrade == 0), comment = "short exit")

//if (strategy.exit("long exit", "long"))
    //downtrade := 1
//else 
   // downtrade := 0