코인룰 스크립트에 기반한 OBV 피라미드 전략

저자:차오장, 날짜: 2023-12-08 15:58:29
태그:

img

전반적인 설명

이 전략은 OBV 피라미드이라고 불립니다. 그것은 OBV 지표에 기초하여 포지션을 개설하고 발생 후 수익을위한 트렌드를 추적하기 위해 피라미드 증가 포지션 접근 방식을 채택합니다.

원칙

이 전략은 트렌드 방향을 결정하기 위해 OBV 지표를 사용합니다. OBV 지표는 거래량 변화에 따라 가격 추세를 판단합니다. 거래량 변화는 시장 참여자의 태도를 반영합니다. OBV 라인이 0을 넘으면 구매력이 강화되고 상승 추세가 형성되는 것을 나타냅니다. 0을 넘으면 판매 압력이 강화되고 하락 추세를 나타냅니다.

이 전략은 OBV가 0을 넘어서면 상승 추세를 확인합니다. 상승 추세가 형성되면 피라미드 상승 포지션 규칙이 설정되어 최대 7 개의 추가 구매를 허용합니다. 수익을 취하고 손실을 중지하는 설정이있는 동안 추세에서 이익을 얻는 것을 목표로합니다.

이점 분석

이 전략의 가장 큰 장점은 트렌드를 추적하고 수익을 창출하기 위해 피라미드 접근 방식을 사용하여 트렌드를 파악하는 것입니다. 또한 수익을 취하고 손실을 중지하는 설정으로 탄탄한 위험 통제가 있습니다.

특히 주요 장점은 다음과 같습니다.

  1. OBV를 이용한 정확한 트렌드 판단
  2. 피라미드 구매로 수익을 위한 트렌드를 추적합니다.
  3. 이윤/손실 중지 통제 위험
  4. 단순하고 명확한 논리

위험 분석

주요 위험은 두 가지 측면에서 나타납니다.

  1. 부적절한 OBV 신호로 인해 놓친 기회나 잘못된 입력
  2. 너무 많은 추가 구매는 위험을 증가시킵니다.

해결책:

  1. OBV 매개 변수를 최적화하여 정확성을 보장합니다.
  2. 통제 가능한 위험을 위해 추가 구매를 합리적으로 제한하십시오.

최적화 방향

주요 최적화 방향:

  1. 더 높은 정확성을 위한 OBV 매개 변수 최적화
  2. 추가 구매의 수와 금액을 최적화
  3. 수익/손실 절감 최적화
  4. OBV에만 의존하는 것을 피하기 위해 다른 지표를 포함합니다.

이것은 전략을 더 안정적이고 통제 가능하고 확장 가능하게 만들 수 있습니다.

결론

전체적으로 이것은 매우 실용적인 전략이다. 트렌드 방향을 결정하기 위해 OBV를 사용하고, 그 다음 수익을 위한 트렌드에 피라미드를 사용합니다. 논리는 쉬운 백테스팅을 위해 간단하고 명확합니다. 적용 가능 가치가 있으며 추가 매개 변수, 위험 및 돈 관리 최적화로 성능이 추가적으로 향상 될 수 있으며 추가 연구가 필요합니다.


/*backtest
start: 2023-11-07 00:00:00
end: 2023-12-07 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/
// © RafaelZioni

//@version=4

strategy(title = " OBV Pyr", overlay = true, pyramiding=5,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 20, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.075)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)

//
fastLength = input(250, title="Fast filter length ", minval=1)
slowLength = input(500,title="Slow filter length",  minval=1)
source=close
v1=ema(source,fastLength)
v2=ema(source,slowLength)
 
//
 
filter=true 
src = close


LengthOBV = input(20)

nv = change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume 
c = cum(nv) 
c_tb = c - sma(c,LengthOBV) 

// Conditions

longCond = crossover(c_tb,0)
//shortCond =crossunder(cnv_tb,0)

//

longsignal  = (v1 > v2 or filter == false ) and longCond
//shortsignal = (v1 < v2 or filter == false ) and shortCond 
 
//set take profit
 
ProfitTarget_Percent = input(3)
Profit_Ticks = close * (ProfitTarget_Percent / 100) / syminfo.mintick
 
//set take profit
 
LossTarget_Percent = input(10)
Loss_Ticks = close * (LossTarget_Percent / 100) / syminfo.mintick
 
 
////Order Placing
//
strategy.entry("Entry 1", strategy.long, when=strategy.opentrades == 0 and longsignal)
//
strategy.entry("Entry 2", strategy.long, when=strategy.opentrades == 1 and longsignal)
//
strategy.entry("Entry 3", strategy.long, when=strategy.opentrades == 2 and longsignal)
//
strategy.entry("Entry 4", strategy.long, when=strategy.opentrades == 3 and longsignal)
//
strategy.entry("Entry 5", strategy.long, when=strategy.opentrades == 4 and longsignal)
//
strategy.entry("Entry 6", strategy.long, when=strategy.opentrades == 5 and longsignal)
//
strategy.entry("Entry 7", strategy.long, when=strategy.opentrades == 6 and longsignal)
//
//
//
if strategy.position_size > 0
    strategy.exit(id="Exit 1", from_entry="Entry 1", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 2", from_entry="Entry 2", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 3", from_entry="Entry 3", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 4", from_entry="Entry 4", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 5", from_entry="Entry 5", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 6", from_entry="Entry 6", profit=Profit_Ticks, loss=Loss_Ticks)
    strategy.exit(id="Exit 7", from_entry="Entry 7", profit=Profit_Ticks, loss=Loss_Ticks)
    


더 많은