
Chiến lược này dựa trên sự giao thoa của hai đường VWAP trong hai chu kỳ khác nhau và kết hợp với chỉ số RSI để xác nhận tín hiệu giao dịch. Một số tín hiệu được tạo ra khi giá vượt qua đường VWAP lên và RSI cao hơn mức bán tháo; Một tín hiệu bị phá vỡ được tạo ra khi giá vượt qua đường VWAP xuống và RSI thấp hơn mức mua quá mức. Chiến lược này nhằm mục đích nắm bắt sự đột phá của giá so với VWAP, đồng thời sử dụng chỉ số RSI để lọc các tín hiệu đột phá giả có thể.
Chiến lược giao dịch trung bình trọng lượng giao dịch với chỉ số giao dịch tương đối mạnh là một phương pháp giao dịch đơn giản và dễ sử dụng để thu được lợi nhuận tiềm năng bằng cách nắm bắt sự đột phá của giá so với VWAP. Tuy nhiên, chiến lược này cũng có các vấn đề như tối ưu hóa tham số, thị trường dao động kém, thiếu quản lý rủi ro.
/*backtest
start: 2023-05-05 00:00:00
end: 2024-05-10 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("VWAP and RSI Strategy with Alerts", overlay=true)
// Inputs
cumulativePeriod = input(20, "Rolling Period for VWAP", minval=1)
rsiPeriod = input(20, "RSI Period", minval=1)
rsiOverbought = input(70, "RSI Overbought Level")
rsiOversold = input(30, "RSI Oversold Level")
tradeQty = input(1, "Trade Quantity", minval=0.01) // Cantidad de la operación
// VWAP Calculation
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
plot(vwapValue, color=color.blue, title="VWAP")
// RSI Calculation
rsiValue = rsi(close, rsiPeriod)
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
// Entry Conditions
longCondition = crossover(close, vwapValue) and rsiValue > rsiOversold
shortCondition = crossunder(close, vwapValue) and rsiValue < rsiOverbought
// Strategy Execution for Entries
if (longCondition)
strategy.entry("Long", strategy.long, qty=tradeQty)
if (shortCondition)
strategy.entry("Short", strategy.short, qty=tradeQty)
// Conditions for Exiting
exitLongCondition = crossunder(close, vwapValue) or rsiValue > rsiOverbought // Salir de long cuando el precio cruce debajo del VWAP o el RSI sea alto
exitShortCondition = crossover(close, vwapValue) or rsiValue < rsiOversold // Salir de short cuando el precio cruce por encima del VWAP o el RSI sea bajo
// Strategy Execution for Exits
strategy.exit("Exit Long", "Long", when=exitLongCondition)
strategy.exit("Exit Short", "Short", when=exitShortCondition)
// Alert Conditions
alertcondition(longCondition, title="Enter Long", message="ENTER-LONG_BINANCE-FUTURES_BTCUSDT_WunderTrading-1_1M_1354a524d74bc295")
alertcondition(exitLongCondition, title="Exit Long", message="EXIT-LONG_BINANCE-FUTURES_BTCUSDT_WunderTrading-1_1M_1354a524d74bc295")
alertcondition(shortCondition, title="Enter Short", message="ENTER-SHORT_BINANCE-FUTURES_BTCUSDT_WunderTrading-1_1M_1354a524d74bc295")
alertcondition(exitShortCondition, title="Exit Short", message="EXIT-SHORT_BINANCE-FUTURES_BTCUSDT_WunderTrading-1_1M_1354a524d74bc295")