Green Price Bar: (13-period EMA > previous 13-period EMA) and
(MACD-Histogram > previous period’s MACD-Histogram)
Red Price Bar: (13-period EMA < previous 13-period EMA) and
(MACD-Histogram < previous period's MACD-Histogram)
Price bars are colored blue when conditions for a Red Price Bar or
Green Price Bar is not met. The MACD-Histogram is based on MACD(12,26,9).
A continuación se muestra un fragmento de código ProRealTime que implementa las condiciones descritas
// Define the Exponential Moving Average (EMA)
EMA13 = ExponentialAverage[13](close)
// Define MACD and its Histogram
MACDValue = MACD[12,26,9](close)
SignalValue = ExponentialAverage[9](MACDValue)
MACDHistogram = MACDValue - SignalValue
// Conditions for Green Price Bar
GreenBar = (EMA13 > EMA13[1]) and (MACDHistogram > MACDHistogram[1])
// Conditions for Red Price Bar
RedBar = (EMA13 < EMA13[1]) and (MACDHistogram < MACDHistogram[1])
// Apply coloring to the price bars
if GreenBar then
DRAWCANDLE(Open, High, Low, Close) COLOURED(0, 128, 0) // Green
elsif RedBar then
DRAWCANDLE(Open, High, Low, Close) COLOURED(255, 0, 0) // Red
else
DRAWCANDLE(Open, High, Low, Close) COLOURED(0, 0, 255) // Blue
endif
RETURN
Este fragmento de código debe añadirse a un gráfico ProRealTime para colorear automáticamente las barras de precios en función de las condiciones especificadas. La función DRAWCANDLE se utiliza para dibujar las velas en los colores especificados: verde para condiciones alcistas, rojo para condiciones bajistas y azul cuando no se cumple ninguna de las dos condiciones. Esto debería ayudar a visualizar las tendencias del mercado según los criterios de EMA y histograma MACD descritos.