Accumulators

Overview


An accumulator is a algorithm that attempts to find the price level where a price series has spent the most time. That is, the price tends to drift toward that level, and tends to stay around that level when there.

Accumulators are sometimes used to discover support/resistance levels.

Calculation


The following represents a sample accumulator using the channel library.


let ch = await import('/lib/finance/technical/v1.0.0/channels.mjs');

let data = $val('Fixed Timeseries');
let level = ch.findAccumulator(data.map(p=>p.price));
let data2 = data.map((p, i, data)=>{
    return {
        date:p.date,
        price:p.price,
        y:level
    }
});