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-nwe-lux

v0.0.1

Published

Nadaraya–Watson envelope indicator

Downloads

7

Readme

indicator-nwe-lux

Nadaraya–Watson envelope derived from the indicator from LuxAlgo with some changes

This version has a 'slow' calculation [which is slow] which is equivalent to running the 'fast' calculation once for every candle in the input [but it only uses prior-data per-candle]. The 'fast' version calculates the value for lookBackLen candles [fast] but 'historic values' change with new data and so the values derived from the fast version may not be appropriate for backtests. They also look a bit different.

Experimental, different than the original, use at your own risk

CC-SA-NC license as per the original. note this module is not supported by/affiliated with LuxAlgo.

Installation

npm i indicator-nwe-lux

Usage

var candles = require('candles-sample-aapl').loadNMinuteCandles(5).slice(-1500);//.slice(50);
var {computeForSingleCandle, computeForAllCandlesFast, computeForAllCandlesSlow} = require('./index.js');

// var h = 14; //orig 8
// var mult = 3; //orig 3
// var lookBackLen = 499;
// var doLog = true; //log iteration count as it runs
// computeForAllCandlesSlow(candles, lookBackLen, h, mult, doLog) //all candles affected - in-place! only uses back-data -- very slow!

//or, if you only care about the last candle ...
// var lastCandleIndex = candles.length-1;
// computeForSingleCandle(candles, lastCandleIndex,  499, h, mult);
// console.log(candles[candles.length-1]);

var h = 14; //orig 8
var mult = 3; //orig 3
var lookBackLen = 499;
//much faster; smoother curve; but 'history may change' with new data. not good for backtesting
candles = computeForAllCandlesFast(candles,  lookBackLen, h, mult); //note -- only the last 499 (lookBackLen) candles are affected

// candles now each have fields {NWEtop:price, NWEbottom:price, buy:bool, sell:bool}
// "buy"/"sell" bools set if price cross below/above curve

var {drawChartForCandles,saveChartForCandles} = require('ohlc-chart-simple');

candles = candles.map(function(candle,index){
    //add shifted signal to the graph as an indicator
    var signalS = candle.NWEbottom;
    var signalT = candle.NWEtop;
    candle.indicators = {
        "T_LINE": signalT,
        "S_LINE": signalS,
        "S_LINE_color": [0,0,0],
        "S_LINE_thickness": 0,
        "T_LINE_color": [0,0,0],
        "T_LINE_thickness": 0
    }
    return candle;
}).slice(-500);

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-fast.png",
}

saveChartForCandles(candles, config);

slow

fast version ^

fast

slow version ^