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-fvg

v0.0.12

Published

tool to tag fair value gaps (FVG's) in OHLCV candles

Downloads

8

Readme

indicator-fvg

tool to tag fair value gaps (FVG's) in OHLCV candles

experimental, use at your own risk

Installation

npm i indicator-fvg

Usage

//candles format [{open, high, low, close, volume}]
var candles = require('candles-sample-aapl').loadNMinuteCandles(15).slice(0,1000);

var {getCandlesGaps, allRectsForGaps} = require('indicator-fvg');

//getCandlesGaps(candles, stdSizeThresh=0, stdWindowSize=100, minGapSizeBeforeClose=0.0, discardGapsAfterNPeriods = 250))
//minGapSizeBeforeClose = minimum gap size before gap is considered 'closed'
//stdSizeThresh = how many standard deviations above average does a candle need to be to start a gap
//stdWindowSize = window size to calculate std value per-candle [eg rolling window using PRIOR candles only]

candles = getCandlesGaps(candles);

//each candle now has the field .gaps if there is at least 1 gap above or below.
//gaps = object with fields corresponding to the start index of each gap
//eg candle.gaps[gapStartIndex+""] = theGap
//where
//theGap = {startIndex: i, lowPrice: bottomOfGapHere , highPrice: topOfGapHere, color: "red" or "green"}
//
//also on candles that initiate gaps:
//candle.gapStart = theGap;

//also adds all these fields to candle

// nearestGapAbove: {
//         startIndex: 985,
//         startingRange: { lowPrice: 145.67, highPrice: 145.96 },
//         lowPrice: 145.67,
//         highPrice: 145.96,
//         color: 'red',
//         indexLastUpdate: 997,
//         distance: 0.709699999999998, //distance to gap in dollars
//         distanceStd: 2.441801922923786 //distance to gap in std of candle size 
// },
// nearestGapBelow: /*similar to above*/,
// sdHere: 0.29064601568918874, //standard deviation of candle size over stdWindowSize
// totalGaps: 20, //total separate gaps above and below
// totalGapsRange: 22.124899999999997, //total range of gaps in dollars
// totalGapsRangeBearish: 9.709299999999985, //total range of bearish [red] gaps in dollars
// totalGapsRangeBullish: 12.415600000000012, //total range of bullish [green] gaps in dollars
// totalGapsBullBearDiff: -4.439600000000041, //bull gap range - bear gap range, dollars
// totalGapsBullBearDiffStd: -15.274938448657986, //(bull gap range - bear gap range, dollars)/std
// totalGapsPercentDecimatedBullish: 0, //if the candle closed inside a green gap, how much of the gap has been decimated so far [%]?
// totalGapsPercentDecimatedBearish: 0, //if the candle closed inside a red gap, how much of the gap has been decimated so far [%]?
// totalGapsChange: 0, //totalGaps here - totalGaps previous candle
// totalGapsChangeBullish: 0, //change in total bull gaps [eg whether this candle has cleared one]
// totalGapsChangeBearish: 0, //change in total bear gaps [eg whether this candle has cleared one]
// totalGapsRangeChange: 0, //change in remaining gaps range, total 
// totalGapsRangeChangeBullish: 0, //change in remaining green gaps range, in dollars
// totalGapsRangeChangeBearish: 0  //change in remaining red gaps range, in dollars
// totalGapsRangeChangeStd: 0, //change in remaining gaps range, total divided by std of candle size over the stdWindow
// totalGapsRangeChangeBullishStd: 0, //change in remaining green gaps range, in dollars divided by std of candle size over the stdWindow
// totalGapsRangeChangeBearishStd: 0  //change in remaining red gaps range, in dollars divided by std of candle size over the stdWindow

//now lets plot the gaps for the last 200 candles
var {drawChartForCandles,saveChartForCandles} = require('ohlc-chart-simple');
candles = candles.slice(-200)
var config = {
    w: Math.floor(1024/2),
    h: Math.floor(700/2),
    profileBucketsTotal: 64,
    profileBucketsWidth: 16,
    volumeBarsHeight: 64,
    bgColor: [0,0,0],

    rectsBelow: allRectsForGaps(candles, [150,0,0],[0,64,0]),

    kdePrices: candles.map(c=>[c.low, 1]), //[value, weight]
    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: false,
    skipDrawPrice: false,
    skipDrawPriceBars: false,
    title: "AAPL",
    filename: "./candlestick-chart.png",
}

saveChartForCandles(candles, config);

gaps

stonks