Embilletados • EMA Cross Suite (8/20/50/200)

Carlostradercr · study · 91 行 · 点赞 189 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=5
indicator("Embilletados • EMA Cross Suite (8/20/50/200)", overlay=true)
 
// ====================== Inputs
grpE = "EMAs"
len8   = input.int(8,   "EMA 8 (rápida)",      group=grpE, minval=1)
len20  = input.int(20,  "EMA 20 (media)",      group=grpE, minval=1)
len50  = input.int(50,  "EMA 50 (intermedia)", group=grpE, minval=1)
len200 = input.int(200, "EMA 200 (lenta)",     group=grpE, minval=1)
 
grpS = "Señales a monitorear"
use_8_20   = input.bool(true, "Cruces 8/20 (Fast Cross)",           group=grpS)
use_20_50  = input.bool(true, "Cruces 20/50 (Mid Cross)",           group=grpS)
use_50_200 = input.bool(true, "Cruces 50/200 (Golden/Death Cross)", group=grpS)
 
grpF = "Filtros"
confirm_close = input.bool(true,  "Confirmar al cierre de vela", group=grpF)
useVolFilter  = input.bool(false, "Requerir volumen ≥ SMA(20)",   group=grpF)
 
grpV = "Visual"
plotEMAs   = input.bool(true,  "Dibujar EMAs",          group=grpV)
showLabels = input.bool(true,  "Etiquetas y marcadores",group=grpV)
paintBars  = input.bool(false, "Teñir velas con señal", group=grpV)
 
// ====================== Cálculos
ema8   = ta.ema(close, len8)
ema20  = ta.ema(close, len20)
ema50  = ta.ema(close, len50)
ema200 = ta.ema(close, len200)
 
volOK = not useVolFilter or (volume >= ta.sma(volume, 20))
 
sig(cond) =>
    cond and (confirm_close ? barstate.isconfirmed : true) and volOK
 
// ====================== Cruces
bull_8_20   = use_8_20   and sig(ta.crossover(ema8,  ema20))
bear_8_20   = use_8_20   and sig(ta.crossunder(ema8,  ema20))
 
bull_20_50  = use_20_50  and sig(ta.crossover(ema20, ema50))
bear_20_50  = use_20_50  and sig(ta.crossunder(ema20, ema50))
 
bull_50_200 = use_50_200 and sig(ta.crossover(ema50, ema200))   // Golden
bear_50_200 = use_50_200 and sig(ta.crossunder(ema50, ema200))  // Death
 
// ====================== Plots (OBLIGATORIO para que dibuje)
plot(series=plotEMAs ? ema8   : na, color=color.new(color.yellow, 0), linewidth=2, title="EMA 8")
plot(series=plotEMAs ? ema20  : na, color=color.new(color.red,    0), linewidth=2, title="EMA 20")
plot(series=plotEMAs ? ema50  : na, color=color.new(color.lime,   0), linewidth=2, title="EMA 50")
plot(series=plotEMAs ? ema200 : na, color=color.new(color.fuchsia,0), linewidth=2, title="EMA 200")
 
// Teñido opcional de velas cuando hay señal
barcolor(color=
     paintBars and (bull_8_20 or bull_20_50 or bull_50_200) ? color.new(color.teal,   0) :
     paintBars and (bear_8_20 or bear_20_50 or bear_50_200) ? color.new(color.maroon, 0) : na)
 
// ====================== Señales visuales (círculos con texto)
circleUpColor   = color.new(color.teal,   0)
circleDownColor = color.new(color.maroon, 0)
 
plotshape(series=showLabels and bull_8_20,   title="Fast Cross ↑ (8/20)",
     style=shape.circle, location=location.belowbar, size=size.tiny,
     color=circleUpColor, text="FAST ↑", textcolor=color.white)
 
plotshape(series=showLabels and bear_8_20,   title="Fast Cross ↓ (8/20)",
     style=shape.circle, location=location.abovebar, size=size.tiny,
     color=circleDownColor, text="FAST ↓", textcolor=color.white)
 
plotshape(series=showLabels and bull_20_50,  title="Mid Cross ↑ (20/50)",
     style=shape.circle, location=location.belowbar, size=size.tiny,
     color=circleUpColor, text="MID ↑", textcolor=color.white)
 
plotshape(series=showLabels and bear_20_50,  title="Mid Cross ↓ (20/50)",
     style=shape.circle, location=location.abovebar, size=size.tiny,
     color=circleDownColor, text="MID ↓", textcolor=color.white)
 
plotshape(series=showLabels and bull_50_200, title="Golden Cross ↑ (50/200)",
     style=shape.circle, location=location.belowbar, size=size.tiny,
     color=circleUpColor, text="GOLDEN ↑", textcolor=color.white)
 
plotshape(series=showLabels and bear_50_200, title="Death Cross ↓ (50/200)",
     style=shape.circle, location=location.abovebar, size=size.tiny,
     color=circleDownColor, text="DEATH ↓", textcolor=color.white)
 
// ====================== Alertas
alertcondition(condition=bull_8_20,   title="Fast Cross ALZA (8/20)",   message="EMA 8 cruza POR ENCIMA de EMA 20")
alertcondition(condition=bear_8_20,   title="Fast Cross BAJA (8/20)",   message="EMA 8 cruza POR DEBAJO de EMA 20")
alertcondition(condition=bull_20_50,  title="Mid Cross ALZA (20/50)",   message="EMA 20 cruza POR ENCIMA de EMA 50")
alertcondition(condition=bear_20_50,  title="Mid Cross BAJA (20/50)",   message="EMA 20 cruza POR DEBAJO de EMA 50")
alertcondition(condition=bull_50_200, title="Golden Cross (50/200)",    message="EMA 50 cruza POR ENCIMA de EMA 200 (GOLDEN)")
alertcondition(condition=bear_50_200, title="Death Cross (50/200)",     message="EMA 50 cruza POR DEBAJO de EMA 200 (DEATH)")

← 返回列表