Daily & Weekly EMA Levels
Latest daily EMA 5/8/21/50 and SMA 100 and weekly EMA 5/8/21/50 as levels on any chart, read from daily and weekly bars.
- D/W EMA
- Built into Spectral
- Updates at bar close
- ema
- sma
- daily
- weekly
- higher timeframe
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
Daily & Weekly EMA Levels draws where the higher-timeframe moving averages sit right now: the latest daily EMA 5, 8, 21 and 50 and the daily SMA 100, and the latest weekly EMA 5, 8, 21 and 50, as labeled horizontal levels on any chart, including intraday charts. The values come from daily and weekly bars that Spectral loads beside the chart's own bars.
How to read it
Each level shows where a daily or weekly moving average currently is relative to intraday price. Levels that cluster mark confluence. A reclaim, a rejection or acceptance above or below a level still has to be judged from price action and volume; a level is a reference, not a signal.
Settings and limitations
Daily levels and Weekly levels switch each group on or off; the EMA and SMA switches choose the periods in both groups (SMA 100 is daily only). A group that is switched off loads no bars. The values use regular-trading-hours daily and weekly bars: two years of daily bars and five years of weekly bars, so even the 100-day SMA and the 50-week EMA have enough history.
Notes
Computes the same values as the built-in Daily/Weekly EMA Levels in Spectral. Each EMA starts from the first bar's close, as the built-in does. The current day and week count as they trade: the daily and weekly bars stay up to date while the chart is open, so the levels follow today's and this week's price, and they start at the last chart bar. Needs schemaVersion 2 (Spectral with auxiliary bars).
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Daily levels | On / off | On | — | Draw the daily EMA and SMA levels, read from daily bars. |
| Weekly levels | On / off | On | — | Draw the weekly EMA levels, read from weekly bars. |
| EMA 5 | On / off | On | — | Draw the 5-period EMA of the daily and weekly groups. |
| EMA 8 | On / off | On | — | Draw the 8-period EMA of the daily and weekly groups. |
| EMA 21 | On / off | On | — | Draw the 21-period EMA of the daily and weekly groups. |
| EMA 50 | On / off | On | — | Draw the 50-period EMA of the daily and weekly groups. |
| SMA 100 | On / off | On | — | Draw the 100-day SMA (daily group only). |
What it draws
Levels
- D EMA 5solid · 1 px · value on the axis
#9AA5B1 - D EMA 8solid · 1 px · value on the axis
#9AA5B1 - D EMA 21solid · 1 px · value on the axis
#9AA5B1 - D EMA 50solid · 1 px · value on the axis
#9AA5B1 - D SMA 100solid · 1 px · value on the axis
#9AA5B1 - W EMA 5solid · 1 px · value on the axis
#9AA5B1 - W EMA 8solid · 1 px · value on the axis
#9AA5B1 - W EMA 21solid · 1 px · value on the axis
#9AA5B1 - W EMA 50solid · 1 px · value on the axis
#9AA5B1
Source
Save it as daily-weekly-ema-levels.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'daily-weekly-ema-levels',
name: 'Daily & Weekly EMA Levels',
shortName: 'D/W EMA',
version: '1.0.1',
author: 'Spectral',
description: 'Latest daily EMA 5/8/21/50 and SMA 100 and weekly EMA 5/8/21/50 as levels on any chart, read from daily and weekly bars.',
pane: 'price',
live: 'none',
inputs: {
showDaily: { type: 'boolean', label: 'Daily levels', default: true, description: 'Draw the daily EMA and SMA levels, read from daily bars.' },
showWeekly: { type: 'boolean', label: 'Weekly levels', default: true, description: 'Draw the weekly EMA levels, read from weekly bars.' },
showEma5: { type: 'boolean', label: 'EMA 5', default: true, description: 'Draw the 5-period EMA of the daily and weekly groups.' },
showEma8: { type: 'boolean', label: 'EMA 8', default: true, description: 'Draw the 8-period EMA of the daily and weekly groups.' },
showEma21: { type: 'boolean', label: 'EMA 21', default: true, description: 'Draw the 21-period EMA of the daily and weekly groups.' },
showEma50: { type: 'boolean', label: 'EMA 50', default: true, description: 'Draw the 50-period EMA of the daily and weekly groups.' },
showSma100: { type: 'boolean', label: 'SMA 100', default: true, description: 'Draw the 100-day SMA (daily group only).' },
},
levels: {
dailyEma5: { label: 'D EMA 5', color: '#9AA5B1', lineWidth: 1, showValue: true },
dailyEma8: { label: 'D EMA 8', color: '#9AA5B1', lineWidth: 1, showValue: true },
dailyEma21: { label: 'D EMA 21', color: '#9AA5B1', lineWidth: 1, showValue: true },
dailyEma50: { label: 'D EMA 50', color: '#9AA5B1', lineWidth: 1, showValue: true },
dailySma100: { label: 'D SMA 100', color: '#9AA5B1', lineWidth: 1, showValue: true },
weeklyEma5: { label: 'W EMA 5', color: '#9AA5B1', lineWidth: 1, showValue: true },
weeklyEma8: { label: 'W EMA 8', color: '#9AA5B1', lineWidth: 1, showValue: true },
weeklyEma21: { label: 'W EMA 21', color: '#9AA5B1', lineWidth: 1, showValue: true },
weeklyEma50: { label: 'W EMA 50', color: '#9AA5B1', lineWidth: 1, showValue: true },
},
auxiliary: {
daily: {
barSize: '1 day',
duration: '2 Y',
useRth: true,
keepUpToDate: true,
when: { all: ['showDaily'], any: ['showEma5', 'showEma8', 'showEma21', 'showEma50', 'showSma100'] },
},
weekly: {
barSize: '1 week',
duration: '5 Y',
useRth: true,
keepUpToDate: true,
when: { all: ['showWeekly'], any: ['showEma5', 'showEma8', 'showEma21', 'showEma50'] },
},
},
docs: {
overview: 'Daily & Weekly EMA Levels draws where the higher-timeframe moving averages sit right now: the latest daily EMA 5, 8, 21 and 50 and the daily SMA 100, and the latest weekly EMA 5, 8, 21 and 50, as labeled horizontal levels on any chart, including intraday charts. The values come from daily and weekly bars that Spectral loads beside the chart\'s own bars.',
howToRead: 'Each level shows where a daily or weekly moving average currently is relative to intraday price. Levels that cluster mark confluence. A reclaim, a rejection or acceptance above or below a level still has to be judged from price action and volume; a level is a reference, not a signal.',
settings: 'Daily levels and Weekly levels switch each group on or off; the EMA and SMA switches choose the periods in both groups (SMA 100 is daily only). A group that is switched off loads no bars. The values use regular-trading-hours daily and weekly bars: two years of daily bars and five years of weekly bars, so even the 100-day SMA and the 50-week EMA have enough history.',
notes: 'Computes the same values as the built-in Daily/Weekly EMA Levels in Spectral. Each EMA starts from the first bar\'s close, as the built-in does. The current day and week count as they trade: the daily and weekly bars stay up to date while the chart is open, so the levels follow today\'s and this week\'s price, and they start at the last chart bar. Needs schemaVersion 2 (Spectral with auxiliary bars).',
},
calculate(ctx) {
const { bars, inputs, ta, auxiliary } = ctx;
const anchor = bars.length - 1;
const latest = (values) => {
for (let index = values.length - 1; index >= 0; index -= 1) {
if (values[index] !== null) return values[index];
}
return null;
};
const level = (enabled, closes, average, length) => {
if (!enabled || anchor < 0 || closes.length === 0) return null;
const price = latest(average(closes, length));
return price === null ? null : { price, fromIndex: anchor };
};
const daily = inputs.showDaily ? ta.source(auxiliary.daily, 'close') : [];
const weekly = inputs.showWeekly ? ta.source(auxiliary.weekly, 'close') : [];
return {
levels: {
dailyEma5: level(inputs.showEma5, daily, ta.ema, 5),
dailyEma8: level(inputs.showEma8, daily, ta.ema, 8),
dailyEma21: level(inputs.showEma21, daily, ta.ema, 21),
dailyEma50: level(inputs.showEma50, daily, ta.ema, 50),
dailySma100: level(inputs.showSma100, daily, ta.sma, 100),
weeklyEma5: level(inputs.showEma5, weekly, ta.ema, 5),
weeklyEma8: level(inputs.showEma8, weekly, ta.ema, 8),
weeklyEma21: level(inputs.showEma21, weekly, ta.ema, 21),
weeklyEma50: level(inputs.showEma50, weekly, ta.ema, 50),
},
};
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/daily-weekly-ema-levels.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


