모멘텀 기반 추세 추종 전략


생성 날짜: 2024-03-11 10:53:50 마지막으로 수정됨: 2024-03-11 10:54:08
복사: 0 클릭수: 620
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

모멘텀 기반 추세 추종 전략

개요

이 전략은 Aroon 지표와 절대 강도 지표 ((ASH) 를 사용하여 시장 추세와 잠재적인 거래 기회를 식별합니다. Aroon은 트렌드의 강도와 방향을 식별하는 데 도움을 주며, ASH는 동력력에 대한 통찰력을 제공합니다.

전략 원칙

이 전략은 두 개의 아론 지표 매개 변수를 사용합니다.

  • 다중 상위 포지션: Aroon 주기는 56 (상기) 와 20 (하계)
  • 공백 위치: Aroon 주기는 17 ° (상철) 및 55 ° (하철)

ASH의 길이는 9개의 K선이며, 클로즈오프 가격을 데이터 소스로 사용합니다.

이 전략에는 특정 입출장 조건이 포함되어 있습니다.

  1. 다단위 포지션 진입: 아론 지표의 하락은 잠재적인 상승 추세를 나타내고, 따라서 다단위 포지션을 개설한다.
  2. 다수 포지션 탈퇴: 아론 지표 아래로 내려가면 다수 포지션 평행
  3. 빈 상점 입점: 아론 지표 아래로 궤도를 밟았을 때 잠재적인 하향 추세를 나타내고, 따라서 빈 상점을 열었다.
  4. 빈 상위 포지션 탈퇴: Aroon 지표에 궤도에 오르면 빈 상위 포지션

우위 분석

이 전략의 가장 큰 장점은 두 가지 지표를 결합하여 사용하는 데 있습니다. 아론 지표는 트렌드 방향과 강도를 효과적으로 판단 할 수 있으며, ASH 지표는 진입 및 퇴출 시간을 판단하는 데 도움이되는 추가 동력 통찰력을 제공합니다.

또한, 두 개의 다른 파라미터 세트의 Aroon 지표를 사용하여 공백 판단을 할 수 있으며, 시장 상황의 변화에 유연하게 적응 할 수 있습니다.

위험 분석

이 전략의 주요 위험은 지표 자체의 한계에 있다. 아론 지표는 충격적인 시장을 정리하는 데 약하고 잘못된 신호를 유발할 수 있다. 아쉬 지표는 단기간에 과도한 반동에도 민감하다.

또한, 매개 변수 설정이 부적절하면 전략 성능에도 영향을 미칠 수 있다. 아론 지표의 길고 짧은 주기와 ASH 지표의 길이를 최적화하고 테스트하여 최적의 매개 변수 조합을 찾아내야 한다.

최적화 방향

가격 돌파구, 거래량 증가 등과 같은 필터를 추가하는 것이 고려될 수 있습니다.

다른 지표의 파라미터 조합과 무게를 테스트하여 최적의 파라미터를 찾을 수 있습니다. 또한 RSI, KD 등과 같은 다른 지표와 결합하여 더 강력한 지표 조합을 형성하여 전략 성능을 향상시킬 수 있습니다.

요약하다

이 전략은 Aroon과 ASH 두 지표의 장점을 통합하여, 두 지표로 확인하여, 트렌드를 판단하고 전환점을 잡는 데 더 효과적입니다. 그러나 파라미터 설정과 지표 자체의 한계는 여전히 최적화가 필요합니다.

전략 소스 코드
/*backtest
start: 2023-03-05 00:00:00
end: 2024-03-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © IkkeOmar

//@version=5
strategy("Aroon and ASH strategy - ETHERIUM [IkkeOmar]", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=1, commission_value=0, slippage=2)


// AROON SETTINGS ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// Inputs for longs 

length_upper_long = input.int(56, minval=15)
length_lower_long = input.int(20, minval=5)

// Inputs for shorts
//Aroon Short Side Inputs
length_upper_short = input.int(17, minval=10)
length_lower_short = input.int(55)

// ABSOLUTE STRENGTH HISTOGRAM SETTINGS ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
length = input(title='Length', defval=9)
src = input(title='Source', defval=close)




// CALCULATIONS: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Aroon
upper_long = 100 * (ta.highestbars(high, length_upper_long + 1) + length_upper_long) / length_upper_long
lower_long = 100 * (ta.lowestbars(low, length_lower_long + 1) + length_lower_long) / length_lower_long

upper_short = 100 * (ta.highestbars(high, length_upper_short + 1) + length_upper_short) / length_upper_short
lower_short = 100 * (ta.lowestbars(low, length_lower_short + 1) + length_lower_short) / length_lower_short

// Ahrens Moving Average
ahma = 0.0
ahma := nz(ahma[1]) + (src - (nz(ahma[1]) + nz(ahma[length])) / 2) / length



// CONDITIONS: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


// Options that configure the backtest start date
startDate = input(title='Start Date', defval=timestamp('01 Jan 2018 00:00'))


// Option to select trade directions
tradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Long')

// Translate input into trading conditions
longOK = tradeDirection == 'Long' or tradeDirection == 'Both'
shortOK = tradeDirection == 'Short' or tradeDirection == 'Both'


// Check if the close time of the current bar falls inside the date range
inDateRange = true

longCondition = ta.crossover(upper_long, lower_long) and inDateRange and lower_long >= 5 and longOK
longCloseCondition = ta.crossunder(upper_long, lower_long) and inDateRange

shortCondition = ta.crossunder(upper_short, lower_short) and inDateRange and shortOK
shortCloseCondition = ta.crossover(upper_short, lower_short) and inDateRange

// Start off with the initial states for the longs and shorts
var in_short_trade = false
var in_long_trade = false

var long_signal = false
var short_signal = false

if longCondition
    long_signal := true
if longCloseCondition
    long_signal := false
    
if shortCondition
    short_signal := true
if shortCloseCondition
    short_signal := false

// While no trades active and short condition is met, OPEN short
if true and in_short_trade == false and in_long_trade == false and shortCondition
    strategy.entry("short", strategy.short, when = shortCondition)
    in_short_trade := true
    in_long_trade := false

// While no trades and long condition is met, OPEN LONG
if true and in_short_trade == false and in_long_trade == false and longCondition
    strategy.entry("long", strategy.long, when = longCondition)
    in_long_trade := true
    in_short_trade := false

    
// WHILE short trade and long condition is met, CLOSE SHORT and OPEN LONG
if true and in_short_trade == true and in_long_trade == false and longCondition
    // strategy.close("short", when = longCondition)
    strategy.entry("long", strategy.long, when = longCondition)
    in_short_trade := false
    in_long_trade := true
    
    
// WHILE long trade and short condition is met, CLOSE LONG and OPEN SHORT
if true and in_short_trade == false and in_long_trade == true and shortCondition
    // strategy.close("long", when = shortCondition)
    strategy.entry("short", strategy.short, when = shortCondition)
    in_short_trade := true
    in_long_trade := false

// WHILE long trade and exit long condition is met, CLOSE LONG
// if short signal is active, OPEN SHORT
if true and in_short_trade == false and in_long_trade == true and longCloseCondition
    if short_signal
        strategy.entry("short", strategy.short, when = short_signal)
        in_long_trade := false
        in_short_trade := true
    else
        strategy.close("long", when = longCloseCondition)
        in_long_trade := false
        in_short_trade := false

// if in short trade only and exit short condition is met, close the short
// if long signal still active, OPEN LONG
if true and in_short_trade == true and in_long_trade == false and shortCloseCondition
    if long_signal
        strategy.entry("long", strategy.long, when = long_signal)
        in_short_trade := false
        in_long_trade := true
    else
        strategy.close("short", when = shortCloseCondition)
        in_short_trade := false
        in_long_trade := false