이동 평균 밴드 브레이크업 전략

저자:차오장, 날짜: 2023-09-17 18:33:57
태그:

전반적인 설명

이 전략은 이동 평균을 사용하여 가격 채널을 형성하고 가격이 채널 대역을 벗어날 때 신호를 생성합니다. 이는 매개 변수 조정을 통해 간단한 긴 / 짧은 포지션을 달성 할 수있는 전형적인 트렌드 다음 전략입니다.

전략 논리

  1. SMA/EMA/WMA/RMA 같은 옵션으로 이동 평균을 계산합니다.

  2. 상단역은 이동평균의 특정 비율 증가율이고 하단역은 특정 비율 감소율입니다.

  3. 상위 범위를 넘어서 긴 거래, 하위 범위를 넘어서 짧은 거래

  4. 스톱 로스를 설정하고 이윤 포인트를 취합니다. 이윤 포인트는 입시 가격의 특정 비율 증가입니다. 스톱 로스 포인트는 입시 가격의 특정 비율 감소입니다.

이점 분석

  1. 이동 평균을 사용하여 트렌드 결정을 구현하기 쉽습니다.

  2. 조정 가능한 매개 변수는 다른 보유 기간과 위험 선호도를 수용합니다.

  3. 선택적인 길고 짧은 방향은 다양한 시장 조건에 적응합니다.

  4. 고정된 비율로 스톱 로스 및 영업이익은 통제 가능하도록 합니다.

위험 분석

  1. 추세가 급격히 변하면 함정에 빠질 가능성이 높습니다.

  2. 부적절한 매개 변수 조정은 과잉 거래 또는 지연 위험을 초래합니다.

  3. 일정한 비율의 스톱 손실/이익은 유연성이 부족합니다.

  4. 이중 방향 거래로 거래 빈도와 수수료가 증가합니다.

최적화 방향

  1. 이동 평균 매개 변수를 최적화하여 지연과 노이즈를 균형 잡습니다.

  2. 채널 대역폭을 최적화하여 시장 변동 빈도에 맞춰야 합니다.

  3. 다른 스톱 로스를 테스트하고 이윤을 얻습니다. 동적 스톱은 더 효과적입니다.

  4. 전체 시장 상황을 측정하기 위해 트렌드 및 오스실레이션 지표를 추가합니다.

  5. 중요한 사건의 영향을 피하기 위해 시간 필터를 구현합니다.

요약

전략은 이동 평균 채널을 통해 단순한 트렌드를 달성하지만 더 강력한 매개 변수 최적화와 위험 통제가 필요합니다. 더 많은 기술적 지표가 전략 논리를 더 향상시키기 위해 도입 될 수 있습니다.


/*backtest
start: 2023-08-17 00:00:00
end: 2023-09-16 00:00:00
period: 1h
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/
// © TaylorTneh
//@version=4

// strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)

price = input(close, title="Source")
mabtype = input(title="Moving Average Type", defval="RMA", options=["SMA", "EMA", "RMA", "WMA"])
malen = input(10, "MA Period : 10")
magap = input(0.6, "Band Gap : 0.6", minval = -10, maxval = 10, step = 0.1)
mabup = if mabtype == "SMA"
    sma(high, malen)
else
    if mabtype == "EMA"
        ema(high, malen)
    else
        if mabtype == "WMA"
            wma(high, malen)
        else
            if mabtype == "RMA"
                rma(high, malen)
                    
mabdn = if mabtype == "SMA"
    sma(low, malen)
else
    if mabtype == "EMA"
        ema(low, malen)
    else
        if mabtype == "WMA"
            wma(low, malen)
        else
            if mabtype == "RMA"
                rma(low, malen)
                    
upex = mabup * (1 + magap/100)
dnex = mabdn * (1 - magap/100)
plot(upex, "Upper MA Band", color.orange)
plot(dnex, "Lower MA Band", color.orange)


//-------------------------------------------- (Strategy)
strategy.entry("Long", strategy.long, stop = upex)
strategy.entry("Short", strategy.short, stop = dnex)
//Long Only//strategy.entry("Long", strategy.long, stop = upex)
//Long Only//strategy.exit("Short", stop = dnex)
//Short Only//strategy.entry("Short", strategy.short, stop = dnex)
//Short Only//strategy.exit("Long", stop = upex)


//-------------------------------------------- (Take Profit & Stop Lose)
stopPer = input(500.0, title='# Stop Loss %', type=input.float) / 100
takePer = input(500.0, title='# Take Profit %', type=input.float) / 100
//Determine where you've entered and in what direction
longStop = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake = strategy.position_avg_price * (1 + takePer)
if strategy.position_size > 0 
    strategy.exit(id="L-TP/SL", stop=longStop, limit=longTake)
if strategy.position_size < 0 
    strategy.exit(id="S-TP/SL", stop=shortStop, limit=shortTake)


//-------------------------------------------- (Sample Time Filter Strategy)
//fromyear = input(2018, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
//toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
//frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
//tomonth = input(10, defval = 10, minval = 01, maxval = 12, title = "To Month")
//fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
//today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//strategy.entry("Long", strategy.long, stop = upex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
//strategy.entry("Short", strategy.short, stop = dnex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
//--------------------------------------------


더 많은