OPEN-SOURCE SCRIPT
Actualizado Trend EMA (MTF) + 4H 200 EMAf

WHAT THIS DOES
Plots a higher-timeframe trend EMA on any chart (default: 60-period EMA of daily closes), colored by its slope: green while rising, red while falling. A second reference line plots the 200 EMA computed on 4-hour bars regardless of your chart timeframe. Floating chips at the end of each line identify them at a glance ("Daily trend EMA" / "4H 200 EMA"), with the trend chip showing a live direction arrow.
KEY FEATURES
- Trend EMA timeframe is selectable: Hourly, 4-Hour, or Daily (length configurable, default 60)
- Slope coloring: the line turns green when rising and red when falling, so trend state is readable without any oscillator
- Hover-to-peek bar coloring: hover over or select the indicator and the price bars instantly color green/red based on whether price is above or below the trend EMA. Click empty chart space and the coloring disappears. No settings required.
- Permanent bar coloring: if you prefer always-on painting, enable it in the Style tab ("Price bar coloring (permanent)")
- Session pinning: EMAs are computed on a fixed data session (Extended 24H by default), so the 4H 200 EMA shows the SAME value whether you view it from a 15-minute, 4-hour, or 3-day chart
- Smart labels: the two chips automatically split apart vertically when the lines converge, so they never overlap
HOW IT WORKS
- The higher-timeframe EMA is requested with gaps enabled, so it prints once per HTF bar and draws as a smooth connected line on intraday charts instead of a stair-step
- Slope state is persisted across the in-between bars, driving the line color, the label color, and the direction arrow
- The data session is pinned via ticker.modify(). Extended-hours data only exists on intraday charts, so an intraday EMA inherited from chart data changes value when you switch to daily+ timeframes. Pinning the session removes that inconsistency, which is a subtle but real problem with most MTF EMA scripts.
- The peek feature works by plotting exact candle copies behind the main price bars, colored by position vs the EMA. TradingView raises a hovered or selected indicator above the main series, which reveals them; deselecting drops them behind the bars again.
HOW TO USE IT
- Trend filter: take longs while the trend EMA is green and price holds above it, shorts while red and below. The bar-peek gives an instant read on how price has interacted with the EMA historically.
- Pullback reference: on intraday charts, the daily trend EMA often acts as a dynamic pullback zone within trends.
- The 4H 200 EMA is a slower structural reference; confluence of the two lines tends to mark meaningful support/resistance zones.
SETTINGS
- Trend EMA: timeframe, length, width, rising/falling colors
- Bar coloring: above/below colors (used by both peek and permanent modes)
- 4H 200 EMA: show/hide, color, width
- Labels: show/hide, offset from last bar
- Data: session used for intraday EMAs (Extended 24H / Regular hours / Chart)
NOTES
- Designed for chart timeframes at or below the selected EMA timeframe. On higher timeframes the intraday EMAs are sampled once per chart bar (coarser but consistent thanks to session pinning).
- The peek feature relies on solid candle/bar styles. With hollow candles, disable the "Bars above/below EMA" plots in the Style tab.
- If bars appear permanently colored after adding the indicator, right-click it and choose Visual order > Send to back.
This is a technical analysis tool for educational purposes, not financial advice.
Plots a higher-timeframe trend EMA on any chart (default: 60-period EMA of daily closes), colored by its slope: green while rising, red while falling. A second reference line plots the 200 EMA computed on 4-hour bars regardless of your chart timeframe. Floating chips at the end of each line identify them at a glance ("Daily trend EMA" / "4H 200 EMA"), with the trend chip showing a live direction arrow.
KEY FEATURES
- Trend EMA timeframe is selectable: Hourly, 4-Hour, or Daily (length configurable, default 60)
- Slope coloring: the line turns green when rising and red when falling, so trend state is readable without any oscillator
- Hover-to-peek bar coloring: hover over or select the indicator and the price bars instantly color green/red based on whether price is above or below the trend EMA. Click empty chart space and the coloring disappears. No settings required.
- Permanent bar coloring: if you prefer always-on painting, enable it in the Style tab ("Price bar coloring (permanent)")
- Session pinning: EMAs are computed on a fixed data session (Extended 24H by default), so the 4H 200 EMA shows the SAME value whether you view it from a 15-minute, 4-hour, or 3-day chart
- Smart labels: the two chips automatically split apart vertically when the lines converge, so they never overlap
HOW IT WORKS
- The higher-timeframe EMA is requested with gaps enabled, so it prints once per HTF bar and draws as a smooth connected line on intraday charts instead of a stair-step
- Slope state is persisted across the in-between bars, driving the line color, the label color, and the direction arrow
- The data session is pinned via ticker.modify(). Extended-hours data only exists on intraday charts, so an intraday EMA inherited from chart data changes value when you switch to daily+ timeframes. Pinning the session removes that inconsistency, which is a subtle but real problem with most MTF EMA scripts.
- The peek feature works by plotting exact candle copies behind the main price bars, colored by position vs the EMA. TradingView raises a hovered or selected indicator above the main series, which reveals them; deselecting drops them behind the bars again.
HOW TO USE IT
- Trend filter: take longs while the trend EMA is green and price holds above it, shorts while red and below. The bar-peek gives an instant read on how price has interacted with the EMA historically.
- Pullback reference: on intraday charts, the daily trend EMA often acts as a dynamic pullback zone within trends.
- The 4H 200 EMA is a slower structural reference; confluence of the two lines tends to mark meaningful support/resistance zones.
SETTINGS
- Trend EMA: timeframe, length, width, rising/falling colors
- Bar coloring: above/below colors (used by both peek and permanent modes)
- 4H 200 EMA: show/hide, color, width
- Labels: show/hide, offset from last bar
- Data: session used for intraday EMAs (Extended 24H / Regular hours / Chart)
NOTES
- Designed for chart timeframes at or below the selected EMA timeframe. On higher timeframes the intraday EMAs are sampled once per chart bar (coarser but consistent thanks to session pinning).
- The peek feature relies on solid candle/bar styles. With hollow candles, disable the "Bars above/below EMA" plots in the Style tab.
- If bars appear permanently colored after adding the indicator, right-click it and choose Visual order > Send to back.
This is a technical analysis tool for educational purposes, not financial advice.
Notas de prensa
Added 200d moving averageScript de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.