Regression Channels

Overview


Implementation


The regression channel can be computed using the channel library.


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

let data = [{:102.24741134846673},-01-06","price":92.05546663621999},{"date":"2000-01-07","price":87.63709379845189},{"date":"2000-01-08","price":82.43592144065678},...];

let coefTop = ch.regressionChannel(data.map(p=>p.price), 1, 1);
let coefBottom = ch.regressionChannel(data.map(p=>p.price), -1, 1);
let coefMid = ch.regressionChannel(data.map(p=>p.price), 0, 10);
let data2 = data.map((p,i)=>{
    return {
        date:p.date,
        price:p.price,
        top:coefTop[0] + i * coefTop[1],
        bottom:coefBottom[0] + i * coefBottom[1],
        mid:coefMid[0] + i * coefMid[1],
    }    
});
					
Try it!