체인 채널 기반 거래 전략

저자:차오장, 날짜: 2024-02-27 14:57:37
태그:

img

전반적인 설명

이것은 입문 및 출구 지점을 결정하기 위해 여러 시간 프레임에 걸쳐 Donchain 채널을 활용하는 거래 전략입니다. 핵심 아이디어는 입구 신호의 더 긴 시간 프레임에서 트렌드 방향을 판단하고 출구 신호의 더 짧은 시간 프레임에서 트렌드 반전을 찾는 것입니다.

전략 논리

이 전략은 주로 채널 상단, 하단 및 중간선으로 구성된 Donchain 채널의 개념을 활용합니다. 채널 폭은 다른 시간 프레임에 따라 다릅니다. 구체적으로 우리는 Donchain 채널을 두 가지 시간대에 걸쳐 구축합니다.

  1. 52개의 기간을 사용하여 더 긴 기간의 도너체인 채널을 구성하고 상위, 하위, 중선을 얻습니다.

  2. 12개의 기간을 사용하여 단기 도너체인 채널을 구성하고 상위, 하위, 중선을 얻습니다.

엔트리 로직: 가격이 장기 채널 상단에 넘을 때, 우리는 그것을 긴 엔트리 신호로 결정합니다. 잘못된 브레이크오웃을 피하기 위해, 우리는 최근 3 개 중 적어도 1 개의 촛불이 채널 상단에 닫혀야합니다.

출구 논리: 가격이 단기 채널 바닥 아래로 넘어갈 때, 우리는 긴 포지션을 닫는 출구 신호로 결정합니다. 마찬가지로, 우리는 파열의 타당성을 확인하기 위해 최근 3 개 중 적어도 1 개의 촛불이 채널 바닥 아래로 닫아야합니다.

장점

  1. 이 전략은 트렌드 추종 및 평균 반전 거래의 장점을 결합합니다. 더 긴 시간 프레임은 트렌드를 판단하고 짧은 시간 프레임은 트렌드 내의 지역 반전을 포착합니다.

  2. 멀티 타임프레임 분석을 이용하면 잘못된 브레이크와 관련된 문제를 해결하고 입출력을 더 유효하게 합니다.

  3. 매개 변수는 다른 제품과 시장 체제에 최적화 될 수 있습니다.

위험 과 해결책

  1. 전략은 매개 변수에 민감합니다. 다른 매개 변수는 크게 다른 결과를 초래할 수 있습니다. 최적의 매개 변수 세트를 찾기 위해 적절한 테스트와 최적화가 필요합니다.

  2. 이는 다양한 시장에서 과도한 거래를 유발할 수 있습니다. 단 하나의 거래 손실을 제어하기 위해 스톱 로스를 사용해야합니다.

  3. 전체 시장 체제를 고려하지 않습니다. 주요 트렌드 반전 지점에서 실패 할 수 있습니다. 주요 트렌드를 측정하기 위해 다른 지표가 사용되어야합니다.

최적화 방향

  1. 채널 기간, 채널 유형 등을 포함한 최상의 매개 변수를 찾기 위해 매개 변수 최적화를 수행합니다.

  2. 손실을 통제하기 위해 합리적인 트레일링 스톱과 함께 스톱 손실 논리를 포함합니다.

  3. 주요 트렌드를 결정하기 위해 다른 지표를 결합하십시오. 예를 들어 EMA, Keltner 채널, MACD 등, 주요 전환점에 실패를 피하십시오.

결론

요약하자면, 이것은 전형적인 다중 시간 프레임 도인체인 채널 브레이크아웃 전략이다. 트렌드 내에서 지역 반전을 포착하기 위해 트렌드 다음과 평균 반전을 모두 잘 통합합니다. 최적화된 매개 변수로 트렌딩 시장에서 매우 잘 수행 할 수 있습니다. 그러나 전략 자체는 매개 변수 및 전반적인 시장 체제에 민감하고 취약합니다. 더 강력한 결과를 달성하기 위해 다른 전략 또는 지표와 결합하는 것이 좋습니다.


/*backtest
start: 2023-02-20 00:00:00
end: 2024-02-26 00:00:00
period: 1d
basePeriod: 1h
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/
// © venkyrocker7777

//@version=5

strategy('Donchain channel based investment strategy', shorttitle='Donchain channel strategy', overlay=true)

Length = input.int(21, minval=1)
xPrice = close
xvnoise = math.abs(xPrice - xPrice[1])
nAMA = 0.0
nfastend = 0.666
nslowend = 0.0645
nsignal = math.abs(xPrice - xPrice[Length])
nnoise = math.sum(xvnoise, Length)
nefratio = nnoise != 0 ? nsignal / nnoise : 0
nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2)
nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
plot(nAMA, color=color.new(color.blue, 0), title='KAMA')

// Function to get Lower Channel, Upper Channel, Middle Channel for a period length
getLCUCMC(PeriodLength) =>
    lowestValueInThePeriod = ta.lowest(PeriodLength)  // LC
    highestValueInThePeriod = ta.highest(PeriodLength)  // UC
    middleChannelInTheperiod = math.avg(highestValueInThePeriod, lowestValueInThePeriod)  // MC
    // Returns Lower Channel, Upper Channel, Middle Channel for a period length
    [lowestValueInThePeriod, highestValueInThePeriod, middleChannelInTheperiod]

// Longer time frame for entry
longerPeriod = 52

// Shorter time frame for exit
shorterPeriod = 12

if timeframe.period == 'D'
    // Longer time frame for entry
    longerPeriod := 52 * 5

    // Shorter time frame for exit
    shorterPeriod := 12 * 5
    shorterPeriod

if timeframe.period == 'M'
    // Longer time frame for entry
    longerPeriod := 12

    // Shorter time frame for exit
    shorterPeriod := 3
    shorterPeriod

// Get Lower Channel, Upper Channel, Middle Channel for longerPeriod, shorterPeriod
[lowestValueInTheLongerPeriodLength, highestValueInTheLongerPeriodLength, middleChannelInLongerperiod] = getLCUCMC(longerPeriod)
[lowestValueInTheShorterPeriodLength, highestValueInTheShorterPeriodLength, middleChannelInShorterperiod] = getLCUCMC(shorterPeriod)


// Plot Upper Channel of longerPeriod in dark green
plot(highestValueInTheLongerPeriodLength, 'highestValueInTheLongerPeriodLength', color=color.new(color.green, 0))

// Plot Lower Channel of shorterPeriod in dark red
plot(lowestValueInTheShorterPeriodLength, 'lowestValueInTheShorterPeriodLength', color=color.new(color.red, 0))

// Entry Plan
// Will start to see if we can enter when high crosses up longer period high (high >= highestValueInTheLongerPeriodLength)
// Check if any of the three past candles and enter when any of the 3 past candles satisfy
// 1) high of that candle >= highestValueInTheLongerPeriodLength of that candle (high[i] >= highestValueInTheLongerPeriodLength[i])
// 2) close of entry point consideration candle is above close of that candle (close > close[i])
isThisPointAnEntry() =>
// Check last 3 bars
    isThisPointAnEntry = false
    offset = 0
    for i = 1 to 3 by 1
        isCurrentCandleALongerPeriodHigh = high >= highestValueInTheLongerPeriodLength
        isCurrentCandleCloseGreaterThanPreiousIthOne = close > close[i]
        isPreviousIthCandleAlsoALongerPeriodHigh = high[i] >= highestValueInTheLongerPeriodLength[i]
        isThisPointAnEntry := isCurrentCandleALongerPeriodHigh and isCurrentCandleCloseGreaterThanPreiousIthOne and isPreviousIthCandleAlsoALongerPeriodHigh
        if isThisPointAnEntry
            offset := -i
            break
    [isThisPointAnEntry, offset]

// Exit Plan - same as entry plan, with things reversed and also on a shorter time frame
// Will start to see if we should exit when low crosses down longer period low (low <= lowestValueInTheShorterPeriodLength)
// Check if any of the three past candles and exit when any of the 3 past candles satisfy
// 1) low of that candle <= highestValueInTheLongerPeriodLength of that candle (low[i] <= lowestValueInTheShorterPeriodLength[i])
// 2) close of exit point consideration candle is below close of that candle (close < close[i])
isThisPointAnExit() =>
// Check last 3 bars
    isThisPointAnExit = false
    for i = 1 to 3 by 1
        isCurrentCandleAShorterPeriodLow = low <= lowestValueInTheShorterPeriodLength
        isCurrentCandleCloseLesserThanPreiousIthOne = close < close[i]
        isPreviousIthCandleAlsoAShorterPeriodLow = low[i] <= lowestValueInTheShorterPeriodLength[i]
        isThisPointAnExit := isCurrentCandleAShorterPeriodLow and isCurrentCandleCloseLesserThanPreiousIthOne and isPreviousIthCandleAlsoAShorterPeriodLow
        break
    isThisPointAnExit

[isEntry, offset] = isThisPointAnEntry()


if isEntry
    strategy.entry('Buy', strategy.long)

strategy.close_all(when=isThisPointAnExit() == true)

if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) - 2 == dayofmonth(time)
    strategy.close_all()



더 많은