Envelopes

Overview

An envelope is an upper bound and lower bound that is calculated as a percentage off of a moving average. to calculate the envelope, the trader needs to specify how the moving average is calculated (size) and whether it is exponentially weighted or not. The size of the percentage offset also needs to be specified.

Implementation

The following sample code utilizes the channels library to calculate the envelope.

let tc = await import('/lib/finance/technical/v1.0.0/channels.mjs'); let prices = [{price:100},{price:101},{price:102},{price:103},{price:104},{price:105},]; //3 day moving average, 0.05 percentage offset, top band let top = tc.envelope(prices.map(p=>p.price), 3, 0.05, true); //3 day moving average, 0.05 percentage offset, bottom band let bottom = tc.envelop(prices.map(p=>p.price), 3, 0.05, false);