0.0.12 • Published 9 months ago

indicator-fvg v0.0.12

Weekly downloads
-
License
GPL
Repository
-
Last release
9 months ago

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

0.0.12

9 months ago

0.0.11

9 months ago

0.0.1

10 months ago