# Candlesticks listener

Candlesticks can be listened through the watchPeriods and timeframes directives.

  • Example
import { MidaMarketWatcher, MidaTimeframe, } from "@reiryoku/mida";

const marketWatcher = new MidaMarketWatcher({ tradingAccount: myAccount, });

await marketWatcher.watch("XAUUSD", {
    watchPeriods: true,
    timeframes: [ MidaTimeframe.H1, ],
});

marketWatcher.on("period-update", (event) => {
    const { period, } = event.descriptor;
    const goldClosePrice = period.close; // Temporary close price
});

marketWatcher.on("period-close", (event) => {
    const { period, } = event.descriptor;
    const goldClosePrice = period.close; // Final close price
});