indicator-auto-avwap-et
v0.0.25
Published
simplified js port of electrifiedtrading's auto-avwap indicator
Downloads
11
Readme
indicator-auto-avwap-et
simplified js port of electrifiedtrading's Auto AVWAP (Anchored-VWAP)
for now, assumes k_mode == EMA and useHiLow == true
includes some additional fields for signals
not affiliated with/supported by electrifiedtrading, experimental, use at your own risk
users of version 0.0.0111: note the slightly different interface as of version 0.0.2
Installation
npm i indicator-auto-avwap-et
Usage
var avwap = require('indicator-auto-avwap-et').autoAVWAP;
//autoAVWAP(candles, useHighLow=true /*else use hlc3*/, lengthRSI=64, lengthStoch=48, smoothK=4, smoothD=4, lowerBand=20, upperBand=80, lowerReversal=20, upperReversal=80)
avwap(candles); //works in-place. adds avwap field to candles.
console.log(candles.slice(-1)[0]);
// {
// date: '2022-12-02T20:00:00.000Z',
// open: 146.9572,
// high: 147.96,
// low: 146.91,
// close: 147.96,
// bid: 146.95,
// ask: 146.96,
// volume: 4031053,
// nSrcCandles: 17,
// avwap: {
// hiAVWAP: 148.0051308002347,
// midAVWAP: 146.24017138078906,
// loAVWAP: 144.47521196134343,
// hiAVWAP_ub: 148.8876105099575,
// loAVWAP_lb: 143.59273225162062,
// hiAVWAP_next: 147.8450881893403,
// loAVWAP_next: 146.07056426189445
// slopeLo: 0.045448547481584, //slope of lo line, dollars per period
// slopeMid: 0.02261289206151673,
// slopeHi: -0.0002227633585505373, //slope of hi line, dollars per period
// buysideIsBullish: true, //true if slopeLo positive, and price above lo
// sellsideIsBearish: false //true if slopeHi negative, and price below hi
// longSignal: false, //candle.avwap.buysideIsBullish && !candle.avwap.sellsideIsBearish
// shortSignal: false // !candle.avwap.buysideIsBullish && candle.avwap.sellsideIsBearish
// longSignalMid: true, //candle.avwap.slopeMid > 0 && candle.close > candle.avwap.midAVWAP
// shortSignalMid: false // candle.avwap.slopeMid < 0 && candle.close < candle.avwap.midAVWAP
// }
// }
//the rest of the code is just for charting...
var {drawChartForCandles,saveChartForCandles} = require('ohlc-chart-simple');
candles = candles.map(function(candle,index){
candle.indicators = {
"hiAVWAP": candle.avwap.hiAVWAP,
"hiAVWAP_color": [128,0,0],
"hiAVWAP_thickness": candle.avwap.sellsideIsBearish ? (candle.avwap.shortSignal ? 3 : 1) : 0,
"midAVWAP": candle.avwap.midAVWAP,
"midAVWAP_color": [128,128,128],//candle.avwap.longSignalMid ? [0,128,0] : (candle.avwap.shortSignalMid ? [128,0,0] : [128,128,128]),
"midAVWAP_thickness": 0,//(candle.avwap.longSignalMid || candle.avwap.shortSignalMid) ? 1 : 0,
"loAVWAP": candle.avwap.loAVWAP,
"loAVWAP_color": [0,128,0],
"loAVWAP_thickness": candle.avwap.buysideIsBullish ? (candle.avwap.longSignal ? 3 : 1) : 0,
//upper, lower bands are like 25% padding on the full ribbon
"hiAVWAPub": candle.avwap.hiAVWAP_ub,
"hiAVWAPub_color": [200,200,200],//candle.avwap.longSignalMid ? [0,128,0] : (candle.avwap.shortSignalMid ? [128,0,0] : [128,128,128]),
"hiAVWAPub_thickness": 0,//(candle.avwap.longSignalMid || candle.avwap.shortSignalMid) ? 1 : 0,
"loAVWAPlb": candle.avwap.loAVWAP_lb,
"loAVWAPlb_color": [200,200,200],//candle.avwap.longSignalMid ? [0,128,0] : (candle.avwap.shortSignalMid ? [128,0,0] : [128,128,128]),
"loAVWAPlb_thickness": 0,//(candle.avwap.longSignalMid || candle.avwap.shortSignalMid) ? 1 : 0,
// "hiAVWAP_next": candle.avwap.hiAVWAP_next,
// "hiAVWAP_next_color": [0,128,0],
// "hiAVWAP_next_thickness": 0,
// "loAVWAP_next": candle.avwap.loAVWAP_next,
// "loAVWAP_next_color": [128,0,0],
// "loAVWAP_next_thickness": 0
}
return candle;
});
var config = {
w: Math.floor(1024/2),
h: Math.floor(700/2),
profileBucketsTotal: 64,
profileBucketsWidth: 16,
volumeBarsHeight: 64,
bgColor: [255,255,255],
//alternative to volume profile: arbitrary kernel density histogram
kdePrices: candles.map(c=>[c.low, 1]), //[value, weight]
// kdeBandwidthDollars: 0.01,
kdeBandwidthPercent: 1.00,
kdeIsGaussian: true, //false == kernel is triangular
kdeColor: [0,0,255],
skipDrawOhlcBars: false,
skipDrawIndicators: false,
skipDrawLegend: false,
expandLegendText: false,
expandTitle: false,
expandPrice: false,
skipDrawDate: true,
skipDrawPrice: false,
skipDrawPriceBars: false,
title: "AAPL",
filename: "./candlestick-chart.png",
}
saveChartForCandles(candles, config);