renko-updater

0.0.111 • Public • Published

renko-updater

given ohlcv candles, produce renko bricks with a callback

note this is different than the way most renko charts are plotted because here each brick is 'set in stone', whereas renko charts normally are re-plotted based on the ATR of the last candle

experimental, use at your own risk

Installation

npm i renko-updater

Usage

var candles = require('candles-sample-aapl').loadNMinuteCandles(60).slice(50);

var drawRenko = require('renko-chart-ascii').drawRenko;
var RenkoUpdater = require('renko-updater').RenkoUpdater;

var onBrickEmitted=function(brick, candle){
    // console.log('got brick', brick, candle);
    // {
    //     direction: 'down',
    //     size: 0.9779076923076935,
    //     isLastBrickForThisCandle: true //because some candles can spawn more than 1 brick!
    // }
}
var atrLen = 14;

//new RenkoUpdater(candles, onBrickEmitted=function(){}, upChar="/",downChar="\\", atrLen=14, MAX_BRICKS_PER_CANDLE=20, lastBrickPerCandleOnly=false, fixedBrickSize=0) //MAX_BRICKS_PER_CANDLE prevent inf loop from weird edge cases like zero atr
var RU = new RenkoUpdater(candles.slice(0,100),onBrickEmitted,"/","\\",atrLen);
var restOfCandles = candles.slice(100);

var i = 0;
var graphString = "";
var interval = setInterval(function(){
    if(i<restOfCandles.length){
        //addCandle(candle, doAddTrail=false, renkoTrailLength=10, doAddMarkov=false, markovLength=renkoTrailLength, markovRetrainNow=candles.length%100==0, markovDists = [1])
        RU.addCandle(restOfCandles[i]);
        var newGraphString = drawRenko(RU.renkoString.slice(-20),"/","\\",true);
        if(newGraphString!==graphString){
            graphString = newGraphString;
            console.log(graphString);
        }
        i++;
    }else{
        clearInterval(interval);
        console.log('end of candles');
    }
},100);

// \
//  \            /\     
//   \          /  \  / 
//    \        /    \/  
//     \      /         
//      \    /          
//       \  /           
//        \/            
//
// end of candles

//example of augmented candle with "renko trail" + markov expectation 

{
  date: '2022-10-03T16:38:00.000Z',
  open: 141.195,
  high: 141.295,
  low: 141.195,
  close: 141.295,
  bid: 141.19,
  ask: 141.2,
  volume: 299019,
  nSrcCandles: 2,
  renkoTrail: '///\\\\\\////',
  renkoMarkovProbsUp: [ 0.6842105263157895 ], //arr of results based on n-periods-to-predict-into-future specified in markovDists [warning -- values beyond [1] produce weird results]
  renkoMarkovProbsDown: [ 0.3157894736842105 ],
  renkoMarkovTransitions: { '/': 52, '\\': 24 } //transitions from current context
}

stonks

Readme

Keywords

none

Package Sidebar

Install

npm i renko-updater

Weekly Downloads

3

Version

0.0.111

License

GPL

Unpacked Size

10.1 kB

Total Files

4

Last publish

Collaborators

  • stonkpunk