# Live indicators
Indicators can be updated in real time using a market watcher.
- Example
import {
createIndicator,
MidaTimeframe,
MidaMarketWatcher,
} from "@reiryoku/mida";
const sma = createIndicator("SMA", { length: 14, });
const m30Periods = await myAccount.getSymbolPeriods("ETHUSD", MidaTimeframe.M30);
const marketWatcher = new MidaMarketWatcher({ tradingAccount: myAccount, });
// Calculate SMA on the M30 close prices
await sma.next(m30Periods.map((period) => period.close));
await marketWatcher.watch("ETHUSD", {
watchPeriods: true,
timeframes: [ MidaTimeframe.M30, ],
});
marketWatcher.on("period-close", async (event) => {
const { period, } = event.descriptor;
// Update the periods
m30Periods.push(period);
// Update the SMA indicator with the new close price
await sma.next([ period.close, ]);
});