
この戦略は,VWAP ((取引量重み平均価格),RSI ((相対的に強い指数) とブリン帯の3つの技術指標を組み合わせて,動的ストップ・ロスを使用して,簡単な使いやすい量化取引戦略を実現する.戦略の主な考えは,VWAP指標を使用して,過去の一段の価格の動きを判断し,同時にRSI指標とブリン帯指標を組み合わせて,価格が超買または超売り領域にあるかどうかを判断して,取引シグナルを決定することです.取引シグナルが決定されたら,戦略は,リスクを制御し,利益をロックするために,ATR (平均真波幅) 指標に基づいて動的ストップ・ロスの価格を計算します.
この戦略は,VWAP,RSI,ブリンベルトの3つの技術指標を組み合わせて,シンプルで使いやすい量化取引戦略を実現している.戦略は,ダイナミックなストップ・ストップ・ロスを採用し,リスクを効果的に制御し,利益をロックすることができます.戦略にはいくつかの潜在的リスクがあるにもかかわらず,合理的なパラメータ設定と継続的な最適化により,この戦略は,実際の取引で良い結果が得られると信じられています.
/*backtest
start: 2024-06-06 00:00:00
end: 2024-06-13 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("VWAP and RSI Strategy", overlay=true)
// VWAP calculation
vwap = ta.vwap(close)
// RSI calculation
rsi_length = 16
rsi = ta.rsi(close, rsi_length)
// Bollinger Bands calculation
bb_length = 14
bb_std = 2.0
[bb_middle, bb_upper, bb_lower] = ta.bb(close, bb_length, bb_std)
// Variables for VWAP signal calculation
backcandles = 15
float vwapsignal = na
// Function to check if last 15 candles are above or below VWAP
calc_vwapsignal(backcandles) =>
upt = true
dnt = true
for i = 0 to backcandles - 1
if close[i] < vwap[i]
upt := false
if close[i] > vwap[i]
dnt := false
if upt and dnt
3
else if upt
2
else if dnt
1
else
0
// Calculate VWAP signal for each bar
vwapsignal := calc_vwapsignal(backcandles)
// Calculate total signal
totalsignal = 0
if vwapsignal == 2 and close <= bb_lower and rsi < 45
totalsignal := 2
else if vwapsignal == 1 and close >= bb_upper and rsi > 55
totalsignal := 1
// Define strategy entry and exit conditions
slatr = 1.2 * ta.atr(7)
TPSLRatio = 1.5
if (totalsignal == 2 and strategy.opentrades == 0)
strategy.entry("Long", strategy.long, stop=close - slatr, limit=close + slatr * TPSLRatio)
if (totalsignal == 1 and strategy.opentrades == 0)
strategy.entry("Short", strategy.short, stop=close + slatr, limit=close - slatr * TPSLRatio)
// Additional exit conditions based on RSI
if (strategy.opentrades > 0)
if (strategy.position_size > 0 and rsi >= 90)
strategy.close("Long")
if (strategy.position_size < 0 and rsi <= 10)
strategy.close("Short")