OPEN-SOURCE SCRIPT
Moving averages. JB style

Moving averages. JB style
A clean, configurable multi-MA overlay. Up to four moving averages, each colored by its own slope, with debounced crossover markers, weight-scaled line widths, an EMA/SMA switch, a regular-hours session lock, and five color palettes — all tuned so the indicator reads as a separate layer over your candles instead of blending into them.
WHAT IT DOES
- Up to 4 moving averages. Defaults are 9 / 21 / 50 / 200, and every slot has its own editable length and show/hide toggle, so you can run one MA or all four. Source is fixed to close to keep the panel simple.
- EMA or SMA from one dropdown. The MA Type dropdown flips all lines between simple and exponential, reusing the same lengths and styling.
- Slope-based coloring. Each line is colored by its own slope: a blue tone when rising, an orange/amber tone when falling, and neutral gray when essentially flat. Colors sit deliberately off the green/red axis so the lines never blend into the candles.
- Weight-scaled widths. Faster MAs are thin, slower MAs are thick, so the long-term anchors stand out at a glance. The slowest MA is drawn as a dotted circle line to mark it as the long-term reference.
- Crossover markers. A hollow ring with a centered dot marks crossovers between adjacent MAs (1x2, 2x3, 3x4) — including the classic 50/200 — a bright bull tone for a bullish cross and an amber tone for a bearish one, placed right at the crossing price.
- Five palettes. Dark, Light, Neon, Ocean, and Solarized. Candles are never recolored on any theme.
WHY IT'S DIFFERENT
Most moving-average indicators just draw lines and color them by whether price is above or below — which whipsaws constantly. This one is built around signal reliability:
1. Slope coloring instead of price-vs-MA coloring. Color reflects whether the average itself is rising or falling — a steadier read of trend than the noisy "is price above the line" flip.
2. A slope deadband kills color flicker. Near-flat averages normally strobe between colors on every tick. Here the slope must clear an ATR-scaled threshold before the color flips; otherwise the line goes neutral. A flat ribbon looks flat — which is itself useful information.
3. Crossovers are MA vs MA, not price vs MA. A faster average crossing a slower one needs agreement between two degrees of smoothing, so it fires far less on noise than a single line being touched by price.
4. A debounce filter removes chop without lagging the signal. The marker fires on the actual crossover, then suppresses further crosses until the two averages genuinely separate (by an ATR-scaled amount) and reconverge. A cluster of back-and-forth chop crosses produces one marker on the real cross — not a smear of noise, and not delayed to a later cross.
5. Confirmed-bar markers don't repaint. A crossover marker appears only after the bar closes, so it never flashes mid-bar and then vanishes.
6. Regular-hours session lock. Every MA (and the ATR behind the filters) is computed from a regular-session feed, so a 200-MA reads the same whether your chart shows extended hours or not. The lines simply hold flat through pre/post-market instead of drifting. On 24/7 instruments this is a harmless no-op.
7. Always the chart's own timeframe. The session lock swaps only the session, never the timeframe — the MAs are always calculated on the timeframe you're viewing.
8. Lines that don't fight the candles. Bull/bear line colors are deliberately blue/orange rather than green/red, so the indicator reads as a clean layer over the candles instead of camouflaging into them.
INPUTS
- Palette: color theme for lines and markers (Dark / Light / Neon / Ocean / Solarized).
- MA Type: SMA or EMA, applied to all lines.
- Regular Hours Only: compute all MAs and ATR from a regular-session feed, regardless of the chart's session.
- Show Crossovers: toggle all crossover markers.
- Slope Deadband (x ATR): minimum slope before the color flips; 0 disables (default 0.02).
- Crossover Min Sep (x ATR): debounce gap — after a marked cross, the next one is suppressed until the MAs separate by this amount and reconverge; 0 disables (default 0.10).
- MA #1-4 Show / Length: per-slot visibility and period (defaults 9 / 21 / 50 / 200).
A clean, configurable multi-MA overlay. Up to four moving averages, each colored by its own slope, with debounced crossover markers, weight-scaled line widths, an EMA/SMA switch, a regular-hours session lock, and five color palettes — all tuned so the indicator reads as a separate layer over your candles instead of blending into them.
WHAT IT DOES
- Up to 4 moving averages. Defaults are 9 / 21 / 50 / 200, and every slot has its own editable length and show/hide toggle, so you can run one MA or all four. Source is fixed to close to keep the panel simple.
- EMA or SMA from one dropdown. The MA Type dropdown flips all lines between simple and exponential, reusing the same lengths and styling.
- Slope-based coloring. Each line is colored by its own slope: a blue tone when rising, an orange/amber tone when falling, and neutral gray when essentially flat. Colors sit deliberately off the green/red axis so the lines never blend into the candles.
- Weight-scaled widths. Faster MAs are thin, slower MAs are thick, so the long-term anchors stand out at a glance. The slowest MA is drawn as a dotted circle line to mark it as the long-term reference.
- Crossover markers. A hollow ring with a centered dot marks crossovers between adjacent MAs (1x2, 2x3, 3x4) — including the classic 50/200 — a bright bull tone for a bullish cross and an amber tone for a bearish one, placed right at the crossing price.
- Five palettes. Dark, Light, Neon, Ocean, and Solarized. Candles are never recolored on any theme.
WHY IT'S DIFFERENT
Most moving-average indicators just draw lines and color them by whether price is above or below — which whipsaws constantly. This one is built around signal reliability:
1. Slope coloring instead of price-vs-MA coloring. Color reflects whether the average itself is rising or falling — a steadier read of trend than the noisy "is price above the line" flip.
2. A slope deadband kills color flicker. Near-flat averages normally strobe between colors on every tick. Here the slope must clear an ATR-scaled threshold before the color flips; otherwise the line goes neutral. A flat ribbon looks flat — which is itself useful information.
3. Crossovers are MA vs MA, not price vs MA. A faster average crossing a slower one needs agreement between two degrees of smoothing, so it fires far less on noise than a single line being touched by price.
4. A debounce filter removes chop without lagging the signal. The marker fires on the actual crossover, then suppresses further crosses until the two averages genuinely separate (by an ATR-scaled amount) and reconverge. A cluster of back-and-forth chop crosses produces one marker on the real cross — not a smear of noise, and not delayed to a later cross.
5. Confirmed-bar markers don't repaint. A crossover marker appears only after the bar closes, so it never flashes mid-bar and then vanishes.
6. Regular-hours session lock. Every MA (and the ATR behind the filters) is computed from a regular-session feed, so a 200-MA reads the same whether your chart shows extended hours or not. The lines simply hold flat through pre/post-market instead of drifting. On 24/7 instruments this is a harmless no-op.
7. Always the chart's own timeframe. The session lock swaps only the session, never the timeframe — the MAs are always calculated on the timeframe you're viewing.
8. Lines that don't fight the candles. Bull/bear line colors are deliberately blue/orange rather than green/red, so the indicator reads as a clean layer over the candles instead of camouflaging into them.
INPUTS
- Palette: color theme for lines and markers (Dark / Light / Neon / Ocean / Solarized).
- MA Type: SMA or EMA, applied to all lines.
- Regular Hours Only: compute all MAs and ATR from a regular-session feed, regardless of the chart's session.
- Show Crossovers: toggle all crossover markers.
- Slope Deadband (x ATR): minimum slope before the color flips; 0 disables (default 0.02).
- Crossover Min Sep (x ATR): debounce gap — after a marked cross, the next one is suppressed until the MAs separate by this amount and reconverge; 0 disables (default 0.10).
- MA #1-4 Show / Length: per-slot visibility and period (defaults 9 / 21 / 50 / 200).
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.