npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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);

chart

stonks