장기적인 헤지 전략

저자:차오장, 날짜: 2023-09-14 16:56:34
태그:

전략 논리

이 전략은 장기적인 추세를 바탕으로 자산 배분과 헤지링을 결정합니다.

논리는 다음과 같습니다.

  1. 기본 자산, 이동 평균 기간 및 결제를 선택

  2. 자산의 간단한 이동 평균을 계산합니다.

  3. MA 이상의 가격 경로를 넘어서면 장기적인 상승을 알립니다. 자산을 길게 이동하십시오.

  4. MA 이하로 넘어가는 가격은 장기적인 하락세를 나타냅니다. 자산을 단축하십시오.

  5. 또한 단기 또는 단기 단기로 갈 수 있습니다

  6. 자산 가격과 MA를 사용하여 장기 트렌드를 판단합니다.

  7. 단기 변동에 대비하기 위해 반대 입장을 취하는 것

이 전략은 단기 리스크를 헤지하고 자산의 세속적 추세에 초점을 맞추고 안정적인 이윤을 허용합니다.

장점

  • 장기적 경향을 결정하기 위한 간단한 MA 시스템

  • 장기/단기 짝은 시스템 리스크를 효과적으로 헤지합니다.

  • 명확한 길고 짧은 신호

위험성

  • MA는 가격 변동에 뒤떨어집니다.

  • 장기 포지션 보유 비용

  • 여러 단계의 리스크 관리 필요

요약

이 전략은 장기 및 단기 자산 조합을 사용하여 위험을 관리하는 것을 강조합니다. 그러나 MA 지연 및 보유 비용은 고려해야합니다.


/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 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/
// © danilogalisteu

//@version=4
strategy("Long Term L/S", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

base = input("BMFBOVESPA:IBOV")
period = input(5, 'SMA Period', input.integer)
resolution = input(title="SMA Resolution", type=input.resolution, defval='M')
strat = input(title="Strategy", defval="Long/Short", options=["Long Only", "Long/Short", "Short Only"])
strat_val = strat == "Long Only" ? 1 : strat == "Long/Short" ? 0 : -1

base_cl = security((base), resolution, close)
base_ma = sma(base_cl, period)

longCondition = crossover(base_cl, base_ma)
if (longCondition)
    if strat_val > -1
        strategy.entry("LONG", strategy.long)
    if strat_val < 1
        strategy.close("SHORT")

shortCondition = crossunder(base_cl, base_ma)
if (shortCondition)
    if strat_val > -1
        strategy.close("LONG")
    if strat_val < 1
        strategy.entry("SHORT", strategy.short)

//plot(longCondition?1:0, 'L', color.blue)
//plot(shortCondition?-1:0, 'S', color.red)

더 많은