
この戦略は,ブリン帯 ((BB) と典型的な価格量平均線 ((VWAP) の2つの指標を組み合わせて,買入と売却の決定を策定する.それは,短期価格の異常を発見して,短線取引に適した取引を行うことができる.
この戦略は,主に以下のルールに基づいて, 買ったり,売ったりします.
トレンドを判断するための前提条件として,高速EMA線が遅いEMA線より高い
VWAPの値が上がったとき,価格上昇と判断して購入する
10K線が,ブリン下線より低い値で閉店した場合は,異常値で購入した.
価格が逆転し,売り切れたと判断する.
具体的には,戦略は50日EMAが200日EMAより高いことを判断し,快速で遅いEMAを使って大トレンドを判断する.そして,VWAPと組み合わせて,短期間に価格が上昇傾向にあるかどうかを判断する.最後に,ブリン帯を使って,短期間の異常な下落が価格に起こったかどうかを判断する.
エクジットルールは,価格がブリン帯線より高いときに,価格が逆転し,退出したと判断する.
この戦略は,複数の指標による価格判断の異常を組み合わせて,エントリー信号の効果を高めることができる.EMAを用いることで,大きなトレンドを判断し,逆転操作を避ける.VWAPを組み合わせて,短期的な価格上昇の機会を捉える.ブリン帯の価格判断の異常を用いることで,ショートラインの取引タイミングを正確に見つけることができる.
これらのリスクに対して,EMA周期パラメータを適切に調整するか,他の大きなトレンド判断指標を試すことができます. VWAPパラメータは,日内データに適用するか,他のショートライン指標に調整することができます. ブリン帯パラメータを調整して最適な幅度を探します.
この戦略は,ブリン帯とVWAPの2つの指標を組み合わせて,短期価格の異常をエントリー時として判断する. 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)