//@version=4
//
study(shorttitle="MACD_X", title="DOBLE MACD X", overlay=false)
vset= input(true, title="Ver Señal de Entrada de Tendencia")
vsct= input(false, title="Ver Señal de Contra Tendencia")
afa= input(true, title="Ver Zona Atlas")
afc= input(true, title="Ver Zona Choppiness")
chopi = input(50.0, title="Nivel Choppiness")
div_reg_al= input(true, title="Ver Divergencias Regulares Alcistas")
div_reg_ba= input(true, title="Ver Divergencias Regulares Bajistas")
div_ocu_al= input(false, title="Ver Divergencias Ocultas Alcistas")
div_ocu_ba= input(false, title="Ver Divergencias Ocultas Bajistas")
etiquetas= input(true, title="Ver Etiquetas De Divergencias")
negro=#000000
amarillo=#FFFF00
gris=#C0C0C0
rojo=#FF0000
blanco=#FFFFFF
verde_fuerte=#0AAC00
// LINEA 0
hline(0, color=negro, linestyle=hline.style_solid, editable=false)
// MACD 1
L1=12
L2=26
tp=close
m0 = ema(tp,L1)
m1 = ema(tp,L2)
macd_1 = (m0-m1)
plot(macd_1, title='Macd 1226', color=gris, linewidth=2, style=plot.style_line, transp=0)
plot(macd_1, title='Macd 1226', color=gris, linewidth=2, style=plot.style_histogram, transp=0)
// MACD 2
L1A=5
L2A=15
tpa=close
m0a = ema(tpa,L1A)
m1a = ema(tpa,L2A)
macd_2 = (m0a-m1a)
plot(macd_2, title='MacD 515', color=amarillo, linewidth=2, style=plot.style_line, transp=0)
plot(macd_2, title='MacD 515', color=amarillo, linewidth=2, style=plot.style_histogram, transp=0)
//Atlas Mini
length = 20
src = close
mult = 2.0
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
dbb = sqrt((upper-lower)/upper)*20
dbbmed = ema(dbb,120)
factor = dbbmed*4/5
atl = dbb-factor
all = atl>0?0:1
bgcolor(afa and all ? rojo : na,title='Zona Atlas', transp=90)
//Choppiness Index
length1 = 14
str = sum(tr,length1)
ltl = lowest(low <= close[1] ? low : close[1],length1)
hth = highest(high >= close[1] ? high : close[1],length1)
height = hth - ltl
chop = 100 * (log10(str / height) / log10(length1))
all1 = chop<chopi?0:1
bgcolor(afc and all1 ? rojo : na,title='Zona Choppiness', transp=90)
//Divergencias
max=highest(macd_2, 100)*1.5
nsc = max
nsv = max*-1
midpoint = (nsc + nsv) / 2
ploff = (nsc - midpoint) / 8
f_top_fractal(_src)=>_src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and _src[2] > _src[0]
f_bot_fractal(_src)=>_src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and _src[2] < _src[0]
f_fractalize(_src)=>f_top_fractal(_src) ? 1 : f_bot_fractal(_src) ? -1 : 0
fractal_top1 = f_fractalize(macd_2) > 0 ? macd_2[2] : na
fractal_bot1 = f_fractalize(macd_2) < 0 ? macd_2[2] : na
high_prev1 = valuewhen(fractal_top1, macd_2[2], 0)[2]
high_price1 = valuewhen(fractal_top1, high[2], 0)[2]
low_prev1 = valuewhen(fractal_bot1, macd_2[2], 0)[2]
low_price1 = valuewhen(fractal_bot1, low[2], 0)[2]
regular_bearish_div1 = fractal_top1 and high[2] > high_price1 and macd_2[2] < high_prev1 and div_reg_ba == true
hidden_bearish_div1 = fractal_top1 and high[2] < high_price1 and macd_2[2] > high_prev1 and div_ocu_ba == true
regular_bullish_div1 = fractal_bot1 and low[2] < low_price1 and macd_2[2] > low_prev1 and div_reg_al == true
hidden_bullish_div1 = fractal_bot1 and low[2] > low_price1 and macd_2[2] < low_prev1 and div_ocu_al == true
col1 = regular_bearish_div1 ? rojo : hidden_bearish_div1 ? rojo : na
col2 = regular_bullish_div1 ? verde_fuerte : hidden_bullish_div1 ? verde_fuerte : na
plot(title='Divergencias Bajistas', series = fractal_top1 ? macd_2[2] : na, color=col1, linewidth=1, offset=-2, transp=0)
plot(title='Divergencias Alcistas', series = fractal_bot1 ? macd_2[2] : na, color=col2, linewidth=1, offset=-2, transp=0)
plotshape(regular_bearish_div1 and div_reg_ba and etiquetas ? macd_2[1] + ploff*0.5 : na, title="Divergencia Regular Bajista", text="🐻 R", location=location.absolute, style=shape.labeldown, size=size.tiny, color=rojo, textcolor=blanco,offset=-2, transp=0)
plotshape(hidden_bearish_div1 and div_ocu_ba and etiquetas ? macd_2[1] + ploff*0.5 : na, title="Divergencia Oculta Bajista", text="🐻 O", location=location.absolute, style=shape.labeldown, size=size.tiny, color=rojo, textcolor=blanco,offset=-2, transp=0)
plotshape(regular_bullish_div1 and div_reg_al and etiquetas ? macd_2[1] - ploff*0.5 : na, title="Divergencia Regular Alcista", text="🐂 R", location=location.absolute, style=shape.labelup, size=size.tiny, color=verde_fuerte, textcolor=blanco,offset=-2, transp=0)
plotshape(hidden_bullish_div1 and div_ocu_al and etiquetas ? macd_2[1] - ploff*0.5 : na, title="Divergencia Oculta Alcista", text="🐂 O", location=location.absolute, style=shape.labelup, size=size.tiny, color=verde_fuerte, textcolor=blanco,offset=-2, transp=0)
//Estrategia
largo = crossover(macd_2,0) and macd_1 < macd_2 and macd_1[1] < macd_1[0] and macd_1 < 0 and vset
largo1 = crossover(macd_2,macd_1) and macd_2 < 0 and vsct
plotshape(largo ? macd_2 - ploff*0.75 : na, title="Largo Entrada de Tendencia", location=location.absolute, style=shape.triangleup, size=size.tiny, color=verde_fuerte, transp=0)
plotshape(largo1 ? macd_2 - ploff*0.75 : na, title="Largo Entrada Contra Tendencia", location=location.absolute, style=shape.triangleup, size=size.tiny, color=verde_fuerte, transp=0)
corto = crossunder(macd_2,0) and macd_1 > macd_2 and macd_1[1] > macd_1[0] and macd_1 > 0 and vset
corto1 = crossunder(macd_2,macd_1) and macd_2 > 0 and vsct
plotshape(corto ? macd_2 + ploff*0.75 : na, title="Corto Entrada de Tendencia", location=location.absolute, style=shape.triangledown, size=size.tiny, color=rojo, transp=0)
plotshape(corto1 ? macd_2 + ploff*0.75 : na, title="Corto Entrada Contra Tendencia", location=location.absolute, style=shape.triangledown, size=size.tiny, color=rojo, transp=0)
//Alertas
alertcondition(largo or largo1,title="Compras")
alertcondition(corto or corto1,title="Ventas")
alertcondition(largo or largo1 or corto or corto1,title="Compras/Ventas")
Overview
Doble MACD X plots fast (5/15) and standard (12/26) MACD lines with histograms to monitor momentum across multiple time horizons. Background shading highlights low volatility compression via the Atlas Mini algorithm and sideways consolidation via the Choppiness Index. The script also identifies regular and hidden bullish or bearish divergences on the faster MACD using fractal pivots.
Dual MACD calculations (12/26 and 5/15 EMAs)
Atlas Mini volatility compression background filter
Choppiness Index consolidation background filter
Fractal-based regular and hidden divergence detection
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Ver Señal de Entrada de Tendencia
bool
true
vset
Ver Señal de Contra Tendencia
bool
false
vsct
Ver Zona Atlas
bool
true
afa
Ver Zona Choppiness
bool
true
afc
Nivel Choppiness
float
50.0
chopi
Ver Divergencias Regulares Alcistas
bool
true
div_reg_al
Ver Divergencias Regulares Bajistas
bool
true
div_reg_ba
Ver Divergencias Ocultas Alcistas
bool
false
div_ocu_al
Ver Divergencias Ocultas Bajistas
bool
false
div_ocu_ba
Ver Etiquetas De Divergencias
bool
true
etiquetas
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator computes a scaled Price Percentage Oscillator divergence between fast and slow lookback periods applied to a minimax-transformed stepline of price data. It generates a weighted divergence line using WMA and EMA smoothing, then plots a scaled ver
This indicator plots the Relative Strength Index in a separate pane from smoothed up and down price changes. It draws the RSI line with horizontal bands at 70, 50 and 30, plus overbought and oversold gradient fills. Optional settings add a smoothing moving ave
This indicator plots the relative strength index in a separate pane. It calculates RSI from the selected source and length with Wilder-style RMA smoothing, then draws the line against horizontal bands at 70, 50 and 30, with gradient fills in the overbought and
This indicator calculates the Relative Strength Index from a chosen price source and length and plots it in a separate pane. It draws horizontal bands at 70, 50, and 30 and fills the area between the outer bands. An optional moving average can smooth the RSI u
This separate-pane indicator plots a MACD line, a signal line, and a histogram whose colors show whether the histogram is rising or falling above or below zero. The oscillator and signal can each use an SMA or an EMA, and an optional marker highlights MACD and
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us