Painting Earnings on a Chart
This script paints Earnings events over candles as bubbles. The bigger is the bubble, the bigger was the analyst surprise on EPS back then. Red bubbles stand for negative surprises, green bubbles stand for positive.
const earnings = await request.earnings(constants.ticker);
const nmdTime = earnings.map(record => record.timestamp);
const surpriseLanded = land_points_onto_series(nmdTime, earnings.map(record => record.eps_surprise_percent), time, 'ge');
const bubbles = for_every(surpriseLanded, close, (surprise, c) => surprise === null ? null : ({ y: c, z: Math.abs(surprise) }));
const bubblesColors = for_every(surpriseLanded, surprise => surprise > 0 ? '#00770055' : '#ff000055');
paint(bubbles, { style: 'bubble', color: bubblesColors });