
Chiến lược này là một hệ thống giao dịch tổng hợp kết hợp nhiều chỉ số trung bình di chuyển ((EMA) giao thoa, độ dao động thực tế ((ATR) và sức đề kháng hỗ trợ điểm trung tâm ((Pivot Points)). Chiến lược này sử dụng tín hiệu giao thoa của EMA ngắn hạn với EMA trung hạn và dài hạn, kết hợp với khu vực dao động của ATR và mức giá quan trọng để nắm bắt các điểm biến đổi xu hướng thị trường, để nắm bắt thời gian giao dịch chính xác.
Chiến lược này dựa trên phân tích kỹ thuật trong ba chiều:
Các quy tắc giao dịch rất rõ ràng:
Chiến lược này xây dựng một hệ thống giao dịch hoàn chỉnh hơn thông qua sự phối hợp hợp hợp tác của nhiều chỉ số kỹ thuật. Ưu điểm cốt lõi của chiến lược là cơ chế xác nhận tín hiệu đa chiều và hệ thống kiểm soát rủi ro tốt, nhưng vẫn cần các nhà giao dịch tối ưu hóa tham số và cải tiến hệ thống theo môi trường thị trường cụ thể.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover + ATR + PPSignal", overlay=true)
//--------------------------------------------------------------------
// 1. Cálculo de EMAs y ATR
//--------------------------------------------------------------------
ema4 = ta.ema(close, 4)
ema9 = ta.ema(close, 9)
ema18 = ta.ema(close, 18)
atrLength = 14
atr = ta.atr(atrLength)
//--------------------------------------------------------------------
// 2. Cálculo de Pivot Points diarios (PPSignal)
// Tomamos datos del día anterior (timeframe D) para calcularlos
//--------------------------------------------------------------------
dayHigh = request.security(syminfo.tickerid, "D", high[1])
dayLow = request.security(syminfo.tickerid, "D", low[1])
dayClose = request.security(syminfo.tickerid, "D", close[1])
// Fórmula Pivot Points estándar
pp = (dayHigh + dayLow + dayClose) / 3.0
r1 = 2.0 * pp - dayLow
s1 = 2.0 * pp - dayHigh
r2 = pp + (r1 - s1)
s2 = pp - (r1 - s1)
r3 = dayHigh + 2.0 * (pp - dayLow)
s3 = dayLow - 2.0 * (dayHigh - pp)
//--------------------------------------------------------------------
// 3. Definir colores para las EMAs
//--------------------------------------------------------------------
col4 = color.green // EMA 4
col9 = color.yellow // EMA 9
col18 = color.red // EMA 18
//--------------------------------------------------------------------
// 4. Dibujar indicadores en el gráfico
//--------------------------------------------------------------------
// EMAs
plot(ema4, title="EMA 4", color=col4, linewidth=2)
plot(ema9, title="EMA 9", color=col9, linewidth=2)
plot(ema18, title="EMA 18", color=col18, linewidth=2)
// ATR
plot(atr, title="ATR", color=color.blue, linewidth=2)
// Pivot Points (PPSignal)
plot(pp, title="Pivot (PP)", color=color.new(color.white, 0), style=plot.style_line, linewidth=1)
plot(r1, title="R1", color=color.new(color.red, 0), style=plot.style_line, linewidth=1)
plot(r2, title="R2", color=color.new(color.red, 0), style=plot.style_line, linewidth=1)
plot(r3, title="R3", color=color.new(color.red, 0), style=plot.style_line, linewidth=1)
plot(s1, title="S1", color=color.new(color.green, 0), style=plot.style_line, linewidth=1)
plot(s2, title="S2", color=color.new(color.green, 0), style=plot.style_line, linewidth=1)
plot(s3, title="S3", color=color.new(color.green, 0), style=plot.style_line, linewidth=1)
//--------------------------------------------------------------------
// 5. Condiciones de cruce (EMA4 vs EMA9 y EMA18) y estrategia
//--------------------------------------------------------------------
crossedAbove = ta.crossover(ema4, ema9) and ta.crossover(ema4, ema18)
crossedBelow = ta.crossunder(ema4, ema9) and ta.crossunder(ema4, ema18)
// Señales de Buy y Sell basadas en cruces + condición con ATR
if crossedAbove and close > ema9 + atr
strategy.entry("Buy", strategy.long)
strategy.exit("Sell", "Buy", stop=ema4)
if crossedBelow and close < ema9 - atr
strategy.entry("Sell", strategy.short)
strategy.exit("Cover", "Sell", stop=ema4)