Overview
A breakout occurs when a price crosses a prior maximum or minimum value of the series. Breakouts require a time period to specify. For example, you could ask for a 20 breakout, which means the point where the price crosses the point where it becomes the maximum value for the last 20 days (or more).
Calculation
The technical.mjs module in the davinci library provides methods for calculating a breakout.
The maxBreakout method will calculate a breakout to the upside, while the minBreakout calculates a breakout to the downside. Each method takes and array of numbers and a size. It will return an array. Each value of the array represents whether a breakout has occurred in the corresponding datapoint.
let tc = await import('/lib/finance/technical/v1.0.0/technical.mjs');
let data = [1,3,7,4,7,12,6,5,9,8,7,10];
let breakout1 = tc.maxBreakout(data, 5);
$console.log(breakout1);
Try it!