
Chiến lược này là một hệ thống giao dịch định lượng dựa trên nhiều chỉ số kỹ thuật, kết hợp chỉ số trung bình di chuyển (EMA), chỉ số tương đối biến động (RVI) và tín hiệu giao dịch tùy chỉnh để đưa ra quyết định giao dịch. Hệ thống sử dụng mục tiêu dừng lỗ và lợi nhuận động, quản lý rủi ro thông qua chỉ số ATR, để thực hiện một khung chiến lược giao dịch toàn diện.
Chiến lược này dựa trên ba thành phần cốt lõi để đưa ra quyết định giao dịch:
Chiến lược này đã xây dựng một hệ thống giao dịch tương đối hoàn chỉnh bằng cách sử dụng tổng hợp nhiều chỉ số kỹ thuật và công cụ quản lý rủi ro. Mặc dù có một số hạn chế vốn có, nhưng hệ thống có khả năng đạt được hiệu suất tốt hơn thông qua hướng tối ưu hóa được đề xuất. Điều quan trọng là phải liên tục giám sát và điều chỉnh trong thực tế để đảm bảo chiến lược có thể duy trì sự ổn định trong các môi trường thị trường khác nhau.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Gold Bot with Viamanchu, EMA20/200, and RVI - 3min", overlay=true)
// Parámetros de las EMAs
ema20 = ta.ema(close, 20)
ema200 = ta.ema(close, 200)
// Relative Volatility Index (RVI)
rvi_length = input(14, title="RVI Length")
rvi = ta.rma(close - close[1], rvi_length) / ta.rma(math.abs(close - close[1]), rvi_length)
// Simulación de Viamanchu (aleatoria para demo, se debe reemplazar por señal de Viamanchu real)
var int seed = time
simulated_vi_manchu_signal = math.random() > 0.5 ? 1 : -1 // 1 para compra, -1 para venta (puedes sustituir por la lógica de Viamanchu)
// Gestión de riesgos: Stop Loss y Take Profit usando ATR
atr_length = input(14, title="ATR Length")
atr = ta.atr(atr_length)
atr_multiplier = input.float(1.5, title="ATR Multiplier for Stop Loss/Take Profit")
stop_loss_level = strategy.position_avg_price - (atr * atr_multiplier)
take_profit_level = strategy.position_avg_price + (atr * atr_multiplier)
// Condiciones de entrada
longCondition = ta.crossover(ema20, ema200) and rvi > 0 and simulated_vi_manchu_signal == 1
shortCondition = ta.crossunder(ema20, ema200) and rvi < 0 and simulated_vi_manchu_signal == -1
// Ejecutar compra (long)
if (longCondition)
strategy.entry("Compra", strategy.long, stop=stop_loss_level, limit=take_profit_level)
// Ejecutar venta (short)
if (shortCondition)
strategy.entry("Venta", strategy.short, stop=stop_loss_level, limit=take_profit_level)
// Visualización de las condiciones de entrada en el gráfico
plotshape(series=longCondition, title="Compra señal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Venta señal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Visualización de las EMAs en el gráfico
plot(ema20, color=color.blue, title="EMA 20")
plot(ema200, color=color.red, title="EMA 200")
// Visualización del RVI en el gráfico
plot(rvi, color=color.green, title="RVI")
hline(0, "Nivel 0", color=color.gray)