anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.15k stars 557 forks source link

how to update last value ? #123

Closed fc01 closed 6 years ago

fc01 commented 6 years ago
let a = new x.SMA({
    period: 3,
    values: [3, 1, 2, 4, 6]
})
console.log(a.getResult())  //[ 2, 2.3333333333333335, 4 ]

//a.updateLastValue(9)  //return 5      //The latest price is real time updates 

let b = new x.SMA({
    period: 3,
    values: [3, 1, 2, 4, 9]
})
console.log(b.getResult())  //[ 2, 2.3333333333333335, 5 ]
anandanand84 commented 6 years ago

There is no update last value. There is only nextValue

slidenerd commented 5 years ago

I double @fc01 you get live data for say a 1 hour chart that updates every second, how are you supposed to get the latest rsi for that duration without recalculating everything

anandanand84 commented 5 years ago

as said there is no update last values there is only nextValue which means you will be able to get the next value after the bar completes and not intermediate updates