Alligator 장기 추세 추종 거래 전략

SMMA SMA
생성 날짜: 2024-05-17 15:40:13 마지막으로 수정됨: 2024-05-17 15:40:13
복사: 4 클릭수: 718
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

Alligator 장기 추세 추종 거래 전략

개요

알리게이터 (영어: Alligator) 장기 트렌드 추적 거래 전략은 윌리엄스 알리게이터 지표를 기반으로 한 정량 거래 전략이다. 이 전략은 시장의 주요 트렌드를 포착하기 위해 다른 주기의 이동 평균 조합을 사용하여 중기 및 장기 트렌드 추적 거래에 적용된다. 전략의 주요 아이디어는 알리게이터 지표의 개시 방향과 가격이 알리게이터 지표와 상대적으로 위치를 판단하여 트렌드의 방향과 강도를 판단하여 거래 결정을 내리는 것이다.

전략 원칙

Alligator의 장기 트렌드 추적 거래 전략은 Alligator 지표를 세 개의 다른 기간의 이동 평균을 사용하여 구성합니다.

  1. Jaw 라인:13 회기 SMMA, 미래로 평평 8 루트 K 라인
  2. Teeth 라인: 8 회기 SMMA, 미래로 평평 5 루트 K 라인
  3. 입술선: 5주기 SMMA, 미래로 평평한 3근 K선

알리거터 지표의 개장 방향이 위쪽으로, 즉 Jaw 라인이 가장 밑에 있고, Teeth 라인이 중간에 있고, Lips 라인이 가장 위에 있고, 가격도 알리거터 지표의 위에 있을 때, 전략은 더 많은 포지션을 만든다. 이러한 상황은 상승 추세 파도가 확인되었다는 것을 나타냅니다. 우리는 추세가 끝날 때까지 그 포지션을 유지하기를 원합니다.

가격이 Jaw 라인을 넘어지면, 전략은 더 많은 상자를 평평하게 만듭니다. 이것은 우리가 곰 시장에서 더 이상 지위를 유지하지 않을 것을 보장합니다.

전략적 이점

  1. 중장기 거래에 적합합니다. 이 전략은 알리거터 지표에 기반하여 시장의 주요 트렌드를 효과적으로 포착할 수 있으며 중장기 트렌드 추적 거래에 적합합니다.
  2. 거래 빈도가 낮다: 전략은 트렌드가 형성될 때만 포지션을 열고, 트렌드가 끝날 때 평점, 거래 빈도가 상대적으로 낮아 거래 비용을 효과적으로 줄일 수 있다.
  3. 적용 범위: 이 전략은 외환, 암호화폐와 같은 다양한 금융 시장에 적용될 수 있으며, 강한 적응력과 유연성을 갖는다.
  4. 최적화 매개 변수: 전략은 시장 추세를 완전히 따르고, 매개 변수를 최적화 할 필요가 없으며, 간단하고 사용하기 쉽습니다.

전략적 위험

  1. 잠재적인 슬라이드 리스크: 시장의 급격한 변동이나 유동성이 부족할 경우 거래 주문이 예상된 가격으로 거래되지 않을 수 있으므로 슬라이드 리스크가 발생할 수 있습니다.
  2. 고정된 위험 관리의 부재: 이 전략에는 고정된 위험 관리 설정이 없으며, 자신의 위험 선호도에 따라 각 거래의 위치 크기를 조정해야 한다.
  3. 단기적 기회를 놓칠 수 있습니다. 중·장기적 트렌드를 포착하는 전략에 집중하기 때문에 단기적 거래 기회를 놓칠 수 있습니다.

전략 최적화 방향

  1. 리스크 관리 모듈을 추가: 위험을 더 잘 제어하기 위해 리스크 관리 조치를 추가하는 것을 고려할 수 있습니다.
  2. 다른 기술 지표와 결합: 전략의 정확성과 신뢰성을 높이기 위해 RSI, MACD 등과 다른 기술 지표와 결합하여 알리거이터를 시도 할 수 있습니다.
  3. 최적화 매개 변수 설정: 이 전략은 최적화 매개 변수가 필요하지 않지만, 최적의 매개 변수 조합을 찾기 위해 다른 시간 주기 및 거래 지표에 대한 재검토를 시도할 수 있다.

요약하다

알리게이터 장기 트렌드 추적 거래 전략은 간단하고 사용하기 쉬운, 적용 범위가 넓은 양적 거래 전략이다. 알리게이터 지표를 사용하여 시장의 주요 트렌드를 포착하여 이 전략은 중장기 동안 안정적인 수익을 얻을 수 있다. 전략에는 몇 가지 잠재적인 위험이 있지만, 위험 관리 모듈을 추가하여 다른 기술 지표와 최적화 파라미터 설정을 결합하는 방법과 같은 방법을 사용하면 전략의 성능과 안정성을 더욱 향상시킬 수 있다. 중장기 트렌드 추적 거래를 선호하는 투자자에게는 알리게이터 장기 트렌드 추적 거래 전략은 고려할 가치가 있는 선택이다.

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

//_______ <licence>
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Skyrex

//_______ <version>
//@version=5

//_______ <declaration_statement>
strategy(title = "Alligator Long Term Trend Following Strategy [Skyrex.io]", 
         shorttitle = "Alligator Strategy [Skyrex.io]", 
         overlay = true, 
         format = format.inherit, 
         pyramiding = 1, 
         calc_on_order_fills = false, 
         calc_on_every_tick = true, 
         default_qty_type = strategy.percent_of_equity, 
         default_qty_value = 100, 
         initial_capital = 10000, 
         currency = currency.NONE,  
         commission_type = strategy.commission.percent, 
         commission_value = 0.1,
         slippage = 5)


//_______ <constant_declarations>
var color skyrexGreen = color.new(#2ECD99, 0)
var color skyrexGray = color.new(#F2F2F2, 0)
var color skyrexWhite = color.new(#FFFFFF, 0)

var color barcolor = na


//_______ <inputs>
// Trading bot settings
sourceUuid = input.string(title = "sourceUuid:", defval = "yourBotSourceUuid", group = "Trading Bot Settings")
secretToken = input.string(title = "secretToken:", defval = "yourBotSecretToken", group = "Trading Bot Settings")

// Trading Period Settings
lookBackPeriodStart = input(title = "Trade Start Date/Time", defval = timestamp('2023-01-01T00:00:00'), group = "Trading Period Settings")
lookBackPeriodStop = input(title = "Trade Stop Date/Time", defval = timestamp('2025-01-01T00:00:00'), group = "Trading Period Settings")

//_______ <function_declarations>
//@function       Used to calculate Simple moving average for Alligator
//@param src      Sourse for smma Calculations
//@param length   Number of bars to calculate smma
//@returns        The calculated smma value 
smma(src, length) =>
    smma =  0.0
    smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length
    smma


//@function       Used to decide if current candle above the Alligator
//@param jaw      Jaw line of an Alligator
//@param teeth    Teeth line of an Alligator
//@param lips     Lips line of an Alligator
//@returns        Bool value  
is_LowAboveAlligator(jaw, teeth, lips) =>
    result = low > jaw and low > lips and low > teeth 
    result


//@function       Used to decide if current candle below the Alligator
//@param jaw      Jaw line of an Alligator
//@param teeth    Teeth line of an Alligator
//@param lips     Lips line of an Alligator
//@returns        Bool value  
is_HighBelowAlligator(jaw, teeth, lips) =>
    result = high < jaw and high < lips and high < teeth 
    result


//@function       Used to decide if Alligator's mouth is open
//@param jaw      Jaw line of an Alligator
//@param teeth    Teeth line of an Alligator
//@param lips     Lips line of an Alligator
//@returns        Bool value 
is_AlligatorHungry(jaw, teeth, lips) =>
    result = lips > jaw[5] and lips > teeth[2] and teeth > jaw[3]
    result


//_______ <calculations>
jaw = smma(hl2, 13)[8]
teeth = smma(hl2, 8)[5]
lips = smma(hl2, 5)[3]


jaw_o = smma(hl2, 13)
teeth_o = smma(hl2, 8)
lips_o = smma(hl2, 5)


//_______ <strategy_calls>
longCondition = is_LowAboveAlligator(jaw, teeth, lips) and is_AlligatorHungry(jaw_o, teeth_o, lips_o) 
if (longCondition)
    strategy.entry(id = "entry1", direction = strategy.long, alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "entry1",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')

if close < jaw
    strategy.close(id = "entry1", alert_message = '{\n"base": "' + syminfo.basecurrency + '",\n"quote": "' + syminfo.currency + '",\n"position": "close",\n"price": "' + str.tostring(close) + '",\n"sourceUuid": "' + sourceUuid + '",\n"secretToken": "' + secretToken + '",\n"timestamp": "' + str.tostring(timenow) + '"\n}')



//_______ <visuals>
if strategy.opentrades > 0
    barcolor := skyrexGreen
else 
    barcolor := skyrexGray

barcolor(barcolor)
//_______ <alerts>