ボリンジャーバンドとVWAPベースの定量取引戦略

作者: リン・ハーンチャオチャン開催日:2024年1月4日 15:59:46
タグ:

img

概要

この戦略は,エントリーと退出の決定をするためにボリンジャーバンド (BB) とボリューム重量平均価格 (VWAP) の指標を組み合わせます. 取引のための短期価格異常を検出することができ,短期取引に適しています.

戦略の論理

この戦略は主に次の入国・出入国規則に基づいている.

  1. トレンドを判断するための前提として,スロー・EMA線上の高速EMA線

  2. 価格が上昇するVWAPより高くなると購入する

  3. 閉じる価格が過去10バーでBBの下帯線を下回った場合,価格異常を示す.

  4. 閉じる価格が価格逆転を示すBB上部帯を超えると売却する

具体的には,50日間のEMAが200日間のEMAよりも高いかどうかを判断し,全体的なトレンドを決定します. その後,価格が短期上昇傾向にあるかどうかを判断するためにVWAPと組み合わせます. 最後に,ボリンジャー帯を使用して,短期的な異常低下をエントリー機会として検出します.

エクシートルールは簡単です 価格がBB上部帯を超えると価格逆転を示します

利点を分析する

この戦略は,エントリーシグナルの有効性を高めるために複数の指標を組み合わせます. EMA を使用して全体的なトレンドを判断することで,トレンドに反する取引は避けられます. VWAPは短期上向きの勢いを捕捉します. BBはエントリーのタイミングとして短期異常を検出します.

リスク分析

  1. EMAの傾向判断が不正確で,トレンドに反する取引が起こります.
  2. VWAP は 時計データや日内データに適しており,日々のデータでは効率が低下しています
  3. BB パラメータの設定が不適切で,幅が広いか狭すぎると信号が欠けている

リスクを軽減するために,EMAとBBのパラメータを調整できます.トレンド検出のために異なる指標をテストします. VWAPを短い時間枠で使用します. 最良の帯域幅のためにBBパラメータを最適化します.

増進 の 機会

  1. MACD のような傾向検出のための他の指標をテストする
  2. EMA と BB パラメータを最適化
  3. ストップ損失メカニズムを追加する
  4. 偽信号を避けるためにフィルターを追加する
  5. 様々な製品と時間枠におけるバックテスト

結論

この戦略は,BBとVWAPを組み合わせて,エントリータイミングとして短期的な価格異常を検出する. EMAを使用して全体的なトレンドを決定することで,トレンドに反する取引を避ける.短期的なモメンタムを迅速に発見することができる.日中および短期取引に適している.パラメータを最適化し,より多くのロジックを組み込むことで安定性と収益性をさらに向上させる.


/*backtest
start: 2023-12-04 00:00:00
end: 2024-01-03 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/
// © mohanee

//@version=4
strategy(title="VWAP and BB strategy [EEMANI]", overlay=true,pyramiding=2, default_qty_value=3, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)
//This strategy combines VWAP and BB indicators
//BUY RULE
//1. EMA50 > EMA 200
//2. if current close > vwap session  value 
//3. check if  price dipped BB lower band for any of last 10 candles
//EXIT RULE
//1. price closes above BB upper band   
//STOP LOSS EXIT
//1. As configured --- default is set to 5%

is_price_dipped_bb(pds,source1) =>
    t_bbDipped=false
    for i=1 to pds
        t_bbDipped:=  (t_bbDipped   or  close[i]<source1) ? true : false
        if t_bbDipped==true
            break
        else
            continue
            
    t_bbDipped
    
// variables  BEGIN
shortEMA = input(50, title="fast EMA", minval=1)
longEMA = input(200, title="slow EMA", minval=1)

//BB

smaLength = input(20, title="BB SMA Length", minval=1)
bbsrc = input(close, title="BB Source")



//addOnDivergence = input(true,title="Add to existing on Divergence")
//exitOption = input(title="exit on RSI or BB", type=input.string, options=["RSI", "BB"],      defval="BB")

//bbSource = input(title="BB  source", type=input.string, options=["close", "vwap"],      defval="close")
     
//vwap_res = input(title="VWAP Resolution", type=input.resolution, defval="session")
stopLoss = input(title="Stop Loss%", defval=5, minval=1)

//variables  END




longEMAval= ema(close, longEMA)
shortEMAval= ema(close, shortEMA)


vwapVal=vwap(close)



// Drawings

//plot emas
plot(longEMAval, color = color.orange, linewidth = 1, transp=0)
plot(shortEMAval, color = color.green, linewidth = 1, transp=0)


//bollinger calculation 
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(bbsrc, smaLength)
dev = mult * stdev(bbsrc, smaLength)
upperBand = basis + dev
lowerBand = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
//bollinger calculation 

//plot bb
//plot(basis, "Basis", color=#872323, offset = offset)
p1 = plot(upperBand, "Upper", color=color.teal, offset = offset)
p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=#198787, transp=95)


plot(vwapVal, color = color.purple, linewidth = 1, transp=0)


// Colour background

barcolor(shortEMAval>longEMAval and close<=lowerBand ? color.yellow: na)
  

//longCondition=  shortEMAval > longEMAval and  close>open and  close>vwapVal
longCondition= shortEMAval >= longEMAval  and  close>=vwapVal and close>open  //      close>vwapVal   and   



//Entry
strategy.entry(id="VWAP_BB LE", comment="VB LE" , long=true,  when= longCondition and  is_price_dipped_bb(10,lowerBand) )  //and strategy.position_size<1 

//add to the existing position
//strategy.entry(id="VWAP_RSI LE", comment="VR LE Add" , long=true,  when= addOnDivergence==true and strategy.position_size>=1 and close<strategy.position_avg_price   and (close<lowerBand or  low<lowerBand) and rsiVal>rsi_buy_line)

barcolor(strategy.position_size>=1  ? color.blue: na)



strategy.close(id="VWAP_BB LE", comment="TP Exit VB LE",   when=crossover(close,upperBand) )

//stoploss
stopLossVal =   strategy.position_avg_price * (1-(stopLoss*0.01) )
strategy.close(id="VB LE", comment="SL Exit",   when= close < stopLossVal)



もっと