bennycode / trading-signals

Technical indicators to run technical analysis with JavaScript & TypeScript. 📈
https://bennycode.com/trading-signals
MIT License
596 stars 90 forks source link

RSI Not accurate? #64

Closed kingkong404 closed 4 years ago

kingkong404 commented 4 years ago

const rsi = new RSI(14)

Get OHLCV data from Binance. ... update with with last 500 (1h) candles using closed value.

rsi.update(Big(candle[4]));
console.log('RSI:', Number(rsi.getResult().valueOf()))

...

https://uk.tradingview.com/chart/WBgn29wN/ - 1h WRXBTC Binance

image

at 4am for example I'm getting
RSI: 63.476620248325204 where as trading view shows 70

image

kingkong404 commented 4 years ago

Actually looks like TradingViews datas not accurate. When I viewed it on binance directly it matched up more although it's still not the same. image

kingkong404 commented 4 years ago

https://www.reddit.com/r/algotrading/comments/7xrw3c/tradingviews_rsi_different_from_my_own_calculation/ might be of help

bennycode commented 4 years ago

Hi @Stevenje, I opened a PR which supports calculating the RSI using SMMA (as specified by J. Welles Wilder Jr.) and EMA (as used by commercial packages like AIQ).

With my PR you will be able to define the sort of moving average you want to use (SMMA is default):

const rsi = new RSI(12, EMA);

Is that to your liking and does it match what is being calculated on TradingView?

kingkong404 commented 4 years ago

@bennyn Yes thats great, thank you!

bennycode commented 4 years ago

Great, can you please provide your test data set so I can write a unit test for using RSI with EMAs?

You wrote that at 4am the RSI should have been "70" and not "63.476620248325204". I would like to guarantee that with a unit test.

kingkong404 commented 4 years ago

{"0":[1597273200000,0.0000111,0.00001113,0.00001096,0.00001112,650403],"1":[1597276800000,0.00001111,0.00001114,0.00001097,0.00001101,457490],"2":[1597280400000,0.00001104,0.00001125,0.00001101,0.00001123,536601],"3":[1597284000000,0.00001123,0.00001123,0.00001089,0.00001093,542504],"4":[1597287600000,0.00001095,0.0000113,0.00001095,0.00001125,755025],"5":[1597291200000,0.00001125,0.00001125,0.00001114,0.00001118,86226],"6":[1597294800000,0.00001118,0.00001459,0.00001112,0.0000138,27663565],"7":[1597298400000,0.0000138,0.0000144,0.00001342,0.00001404,11993865],"8":[1597302000000,0.00001405,0.00001455,0.00001351,0.00001363,7425871],"9":[1597305600000,0.00001363,0.00001386,0.00001279,0.00001335,7667099],"10":[1597309200000,0.00001336,0.00001366,0.00001273,0.00001364,4127903],"11":[1597312800000,0.0000136,0.00001373,0.00001325,0.00001364,2958332],"12":[1597316400000,0.00001366,0.00001377,0.00001304,0.00001326,2504407],"13":[1597320000000,0.00001327,0.00001429,0.00001311,0.00001423,2800651],"14":[1597323600000,0.00001425,0.0000154,0.00001371,0.0000154,10812605],"15":[1597327200000,0.00001541,0.00001594,0.00001501,0.00001523,11018709],"16":[1597330800000,0.00001523,0.00001556,0.00001474,0.00001541,5746212],"17":[1597334400000,0.00001546,0.00001621,0.00001507,0.00001602,5086527],"18":[1597338000000,0.000016,0.00001602,0.00001492,0.00001512,4524964],"19":[1597341600000,0.00001517,0.00001548,0.00001506,0.00001525,1554107],"20":[1597345200000,0.00001521,0.00001601,0.00001515,0.00001565,2060949],"21":[1597348800000,0.00001564,0.00001642,0.00001511,0.0000155,6019629],"22":[1597352400000,0.0000155,0.00001575,0.00001477,0.00001487,4241483],"23":[1597356000000,0.00001487,0.00001553,0.0000146,0.00001544,2521224],"24":[1597359600000,0.00001544,0.0000156,0.00001494,0.00001514,1743977],"25":[1597363200000,0.00001509,0.00001514,0.00001464,0.00001476,1432207],"26":[1597366800000,0.00001476,0.00001534,0.00001457,0.00001472,1498507],"27":[1597370400000,0.00001472,0.00001492,0.00001431,0.00001433,1981461],"28":[1597374000000,0.00001432,0.00001447,0.00001379,0.00001416,4068691],"29":[1597377600000,0.00001415,0.00001447,0.00001403,0.00001421,1593683],"30":[1597381200000,0.00001422,0.00001476,0.00001419,0.00001449,2673964],"31":[1597384800000,0.00001451,0.00001474,0.00001432,0.00001463,1707756],"32":[1597388400000,0.00001463,0.0000149,0.00001393,0.00001437,4891248],"33":[1597392000000,0.00001437,0.00001464,0.00001422,0.00001439,1199617],"34":[1597395600000,0.00001435,0.00001442,0.00001406,0.0000144,1443432],"35":[1597399200000,0.00001441,0.00001442,0.000014,0.00001407,1276083],"36":[1597402800000,0.00001407,0.00001422,0.00001404,0.00001421,721645],"37":[1597406400000,0.00001421,0.00001457,0.00001407,0.00001408,2487577],"38":[1597410000000,0.00001408,0.00001423,0.00001386,0.00001408,1586523],"39":[1597413600000,0.0000141,0.00001419,0.000014,0.00001405,1186189],"40":[1597417200000,0.00001407,0.0000145,0.00001407,0.00001439,2136919],"41":[1597420800000,0.00001438,0.00001444,0.00001382,0.00001414,1495775],"42":[1597424400000,0.00001414,0.00001418,0.00001385,0.00001395,864222],"43":[1597428000000,0.00001393,0.00001444,0.00001388,0.00001429,2749698],"44":[1597431600000,0.00001429,0.00001516,0.00001429,0.00001479,3223613],"45":[1597435200000,0.00001479,0.00001499,0.00001464,0.00001471,781471],"46":[1597438800000,0.00001472,0.00001489,0.00001459,0.00001488,520896],"47":[1597442400000,0.00001488,0.00001533,0.00001484,0.00001505,1093147],"48":[1597446000000,0.00001504,0.00001507,0.00001456,0.00001478,640941],"49":[1597449600000,0.00001475,0.00001475,0.00001397,0.00001416,1545291],"50":[1597453200000,0.00001416,0.00001431,0.00001405,0.00001413,580644],"51":[1597456800000,0.00001417,0.00001447,0.00001398,0.00001446,659817],"52":[1597460400000,0.00001442,0.00001452,0.00001417,0.0000143,973339],"53":[1597464000000,0.0000143,0.00001456,0.00001425,0.00001456,438702],"54":[1597467600000,0.00001456,0.00001456,0.00001415,0.00001426,653345],"55":[1597471200000,0.00001426,0.00001431,0.00001415,0.00001428,447532],"56":[1597474800000,0.00001428,0.00001637,0.00001425,0.00001611,13598041],"57":[1597478400000,0.00001611,0.00001628,0.00001359,0.00001426,17452020],"58":[1597482000000,0.00001428,0.00001455,0.00001384,0.00001392,4026578],"59":[1597485600000,0.00001396,0.00001449,0.00001347,0.00001376,10812904],"60":[1597489200000,0.00001376,0.00001388,0.00001368,0.0000138,1280263],"61":[1597492800000,0.00001381,0.00001389,0.00001347,0.00001364,1500579],"62":[1597496400000,0.00001365,0.00001377,0.00001342,0.0000136,1386960],"63":[1597500000000,0.0000136,0.00001369,0.00001335,0.0000136,994592],"64":[1597503600000,0.00001358,0.00001362,0.0000132,0.0000134,1892727],"65":[1597507200000,0.00001339,0.00001355,0.00001327,0.00001353,697268],"66":[1597510800000,0.00001356,0.00001358,0.00001336,0.00001352,485216],"67":[1597514400000,0.00001351,0.00001378,0.00001347,0.00001361,1271030],"68":[1597518000000,0.00001361,0.00001366,0.00001334,0.0000136,2165834],"69":[1597521600000,0.0000136,0.00001361,0.00001326,0.00001328,740048],"70":[1597525200000,0.00001327,0.0000134,0.00001296,0.00001317,1556859],"71":[1597528800000,0.00001316,0.0000133,0.00001304,0.00001322,474843],"72":[1597532400000,0.00001322,0.00001347,0.00001315,0.00001335,561586],"73":[1597536000000,0.00001336,0.00001341,0.00001315,0.00001328,383368],"74":[1597539600000,0.00001328,0.00001329,0.00001315,0.00001321,253084],"75":[1597543200000,0.00001316,0.00001337,0.00001314,0.00001323,330311],"76":[1597546800000,0.00001322,0.00001333,0.00001301,0.00001317,570085],"77":[1597550400000,0.0000132,0.00001368,0.00001312,0.00001324,2381091],"78":[1597554000000,0.00001327,0.00001343,0.00001319,0.00001321,568003],"79":[1597557600000,0.00001322,0.00001429,0.00001319,0.00001374,5114480],"80":[1597561200000,0.00001371,0.00001386,0.00001351,0.0000138,822024],"81":[1597564800000,0.0000138,0.00001418,0.00001371,0.00001379,2047593],"82":[1597568400000,0.0000138,0.00001392,0.00001365,0.00001365,477530],"83":[1597572000000,0.00001365,0.00001371,0.00001355,0.00001366,599904],"84":[1597575600000,0.00001369,0.00001376,0.00001344,0.00001352,548371],"85":[1597579200000,0.00001348,0.00001359,0.00001333,0.00001349,576202],"86":[1597582800000,0.0000135,0.00001388,0.00001344,0.0000137,492466],"87":[1597586400000,0.0000137,0.00001391,0.00001363,0.00001363,557992],"88":[1597590000000,0.00001372,0.00001372,0.00001346,0.00001352,400288],"89":[1597593600000,0.00001353,0.00001353,0.00001339,0.00001352,471828],"90":[1597597200000,0.00001351,0.00001361,0.0000135,0.00001356,177031],"91":[1597600800000,0.00001356,0.00001376,0.00001351,0.0000137,564946],"92":[1597604400000,0.0000137,0.0000137,0.00001348,0.00001361,455428],"93":[1597608000000,0.00001361,0.000014,0.00001354,0.00001383,1867883],"94":[1597611600000,0.00001383,0.00001388,0.00001371,0.00001385,373537],"95":[1597615200000,0.00001385,0.00001386,0.00001368,0.00001369,158343],"96":[1597618800000,0.00001367,0.00001388,0.00001364,0.00001366,648515],"97":[1597622400000,0.00001365,0.00001381,0.00001362,0.00001369,176125],"98":[1597626000000,0.00001369,0.00001387,0.00001365,0.00001379,362804],"99":[1597629600000,0.00001379,0.00001389,0.00001375,0.00001381,335017],"100":[1597633200000,0.00001381,0.00001381,0.00001321,0.00001342,5129838],"101":[1597636800000,0.00001342,0.00001345,0.00001276,0.00001308,7241734],"102":[1597640400000,0.00001307,0.00001319,0.00001293,0.00001299,1874085],"103":[1597644000000,0.00001299,0.00001302,0.00001286,0.000013,1061241],"104":[1597647600000,0.000013,0.000013,0.00001284,0.00001291,1102142],"105":[1597651200000,0.00001293,0.00001302,0.00001293,0.00001301,1183920],"106":[1597654800000,0.00001301,0.0000131,0.00001294,0.0000131,1250121],"107":[1597658400000,0.0000131,0.0000131,0.00001294,0.00001308,631634],"108":[1597662000000,0.00001308,0.00001311,0.00001294,0.000013,685119],"109":[1597665600000,0.00001299,0.0000131,0.00001285,0.00001297,944426],"110":[1597669200000,0.000013,0.00001302,0.00001233,0.00001245,3223309],"111":[1597672800000,0.00001245,0.00001249,0.00001216,0.00001248,2012987],"112":[1597676400000,0.00001246,0.00001254,0.00001195,0.00001204,2727950],"113":[1597680000000,0.00001206,0.00001244,0.00001203,0.00001239,1233691],"114":[1597683600000,0.00001238,0.00001259,0.0000123,0.00001245,3893726],"115":[1597687200000,0.00001244,0.00001258,0.00001239,0.00001239,500339],"116":[1597690800000,0.0000124,0.00001258,0.00001234,0.0000124,554309],"117":[1597694400000,0.00001245,0.00001246,0.00001233,0.00001236,479883],"118":[1597698000000,0.00001236,0.0000124,0.00001231,0.00001237,275550],"119":[1597701600000,0.00001237,0.00001253,0.00001227,0.00001231,583733],"120":[1597705200000,0.00001231,0.00001234,0.00001223,0.00001231,325419],"121":[1597708800000,0.00001231,0.00001246,0.00001225,0.00001243,470587],"122":[1597712400000,0.00001244,0.00001251,0.00001243,0.00001251,333741],"123":[1597716000000,0.00001251,0.00001251,0.00001232,0.00001232,598349],"124":[1597719600000,0.00001234,0.00001248,0.00001232,0.00001242,353493],"125":[1597723200000,0.00001242,0.00001249,0.0000123,0.00001235,286964],"126":[1597726800000,0.00001236,0.00001246,0.00001226,0.0000124,432617],"127":[1597730400000,0.00001243,0.00001243,0.00001221,0.00001225,556979],"128":[1597734000000,0.00001226,0.00001252,0.00001225,0.00001244,434728],"129":[1597737600000,0.00001244,0.00001262,0.00001243,0.00001261,513090],"130":[1597741200000,0.00001262,0.00001266,0.00001251,0.00001258,224919],"131":[1597744800000,0.00001257,0.00001258,0.00001234,0.00001235,517625],"132":[1597748400000,0.0000124,0.00001244,0.00001234,0.00001234,110014],"133":[1597752000000,0.00001236,0.00001236,0.00001228,0.00001234,226281],"134":[1597755600000,0.00001233,0.00001237,0.00001213,0.00001215,348897],"135":[1597759200000,0.00001215,0.00001231,0.00001203,0.00001214,934210],"136":[1597762800000,0.00001214,0.00001232,0.00001199,0.00001206,788921],"137":[1597766400000,0.00001207,0.00001232,0.00001207,0.00001229,436886],"138":[1597770000000,0.00001229,0.0000123,0.00001217,0.00001227,317162],"139":[1597773600000,0.00001225,0.00001238,0.00001223,0.00001231,296287],"140":[1597777200000,0.00001232,0.00001237,0.00001225,0.00001228,298173],"141":[1597780800000,0.00001228,0.00001228,0.00001205,0.00001213,264765],"142":[1597784400000,0.00001212,0.0000123,0.0000121,0.00001213,492728],"143":[1597788000000,0.00001213,0.00001218,0.00001199,0.00001204,302621],"144":[1597791600000,0.00001202,0.00001211,0.00001199,0.00001203,149384],"145":[1597795200000,0.00001203,0.00001218,0.00001203,0.00001218,173624],"146":[1597798800000,0.00001214,0.00001215,0.00001208,0.00001211,174996],"147":[1597802400000,0.00001211,0.00001211,0.00001156,0.00001182,1669916],"148":[1597806000000,0.00001183,0.00001183,0.00001151,0.00001157,582822],"149":[1597809600000,0.00001156,0.00001167,0.00001114,0.00001128,2792370],"150":[1597813200000,0.0000113,0.00001141,0.00001124,0.00001131,745548],"151":[1597816800000,0.00001128,0.00001147,0.00001104,0.00001146,921013],"152":[1597820400000,0.00001145,0.00001157,0.00001129,0.00001151,623184],"153":[1597824000000,0.00001151,0.00001153,0.00001131,0.00001136,981678],"154":[1597827600000,0.00001139,0.00001158,0.00001137,0.00001154,289599],"155":[1597831200000,0.00001154,0.00001156,0.00001135,0.00001142,564906],"156":[1597834800000,0.0000114,0.00001164,0.00001136,0.00001159,639919],"157":[1597838400000,0.00001161,0.00001167,0.0000115,0.00001152,231188],"158":[1597842000000,0.00001152,0.00001162,0.0000115,0.00001157,256329],"159":[1597845600000,0.00001157,0.00001168,0.00001147,0.00001156,602737],"160":[1597849200000,0.00001155,0.00001155,0.00001132,0.00001137,402445],"161":[1597852800000,0.00001137,0.00001148,0.00001132,0.00001142,271361],"162":[1597856400000,0.00001142,0.00001149,0.00001138,0.00001144,92807],"163":[1597860000000,0.00001145,0.00001152,0.00001131,0.00001144,381347],"164":[1597863600000,0.00001143,0.00001145,0.00001113,0.00001122,273602],"165":[1597867200000,0.00001123,0.00001141,0.00001104,0.00001136,564881],"166":[1597870800000,0.00001138,0.00001168,0.00001131,0.0000115,562263],"167":[1597874400000,0.0000115,0.0000117,0.0000115,0.0000115,241414],"168":[1597878000000,0.00001152,0.00001152,0.00001137,0.00001139,167077],"169":[1597881600000,0.0000114,0.00001161,0.0000114,0.00001159,317115],"170":[1597885200000,0.00001159,0.00001162,0.00001148,0.0000116,219192],"171":[1597888800000,0.0000116,0.00001168,0.00001155,0.0000116,193890],"172":[1597892400000,0.0000116,0.0000116,0.00001138,0.00001138,297392],"173":[1597896000000,0.0000114,0.00001148,0.00001135,0.0000114,207186],"174":[1597899600000,0.00001142,0.00001172,0.00001142,0.00001172,455569],"175":[1597903200000,0.00001171,0.00001212,0.00001169,0.0000121,1916770],"176":[1597906800000,0.00001209,0.00001212,0.00001189,0.00001204,697185],"177":[1597910400000,0.00001204,0.00001207,0.00001179,0.00001182,428790],"178":[1597914000000,0.00001182,0.00001202,0.00001182,0.00001195,538265],"179":[1597917600000,0.00001196,0.00001209,0.00001193,0.00001201,289167],"180":[1597921200000,0.00001201,0.00001227,0.00001201,0.00001213,1338997],"181":[1597924800000,0.00001211,0.00001213,0.00001187,0.00001188,1139460],"182":[1597928400000,0.00001192,0.0000121,0.0000119,0.00001201,371019],"183":[1597932000000,0.00001202,0.00001205,0.0000119,0.00001191,195449],"184":[1597935600000,0.0000119,0.000012,0.00001186,0.0000119,347172],"185":[1597939200000,0.00001191,0.00001195,0.00001176,0.00001182,328915],"186":[1597942800000,0.00001182,0.00001208,0.00001182,0.00001207,281966],"187":[1597946400000,0.00001205,0.00001212,0.0000118,0.00001181,600810],"188":[1597950000000,0.00001181,0.00001185,0.0000117,0.00001177,295724],"189":[1597953600000,0.00001178,0.00001195,0.00001176,0.00001194,218677],"190":[1597957200000,0.00001193,0.00001193,0.0000115,0.00001165,902316],"191":[1597960800000,0.00001163,0.0000118,0.00001163,0.00001173,319441],"192":[1597964400000,0.0000117,0.00001189,0.0000117,0.00001179,238986],"193":[1597968000000,0.00001181,0.00001183,0.00001175,0.00001176,156951],"194":[1597971600000,0.00001176,0.00001194,0.00001173,0.00001191,288227],"195":[1597975200000,0.00001192,0.00001198,0.0000118,0.00001185,384336],"196":[1597978800000,0.00001181,0.0000123,0.00001177,0.00001207,1459068],"197":[1597982400000,0.00001203,0.00001226,0.00001197,0.00001197,607613],"198":[1597986000000,0.00001199,0.00001233,0.00001196,0.00001229,640708],"199":[1597989600000,0.0000123,0.00001233,0.00001215,0.00001225,388344],"200":[1597993200000,0.00001222,0.0000128,0.00001208,0.00001266,2839725],"201":[1597996800000,0.00001266,0.00001288,0.0000125,0.00001277,1228663],"202":[1598000400000,0.00001275,0.00001282,0.00001244,0.00001245,615507],"203":[1598004000000,0.00001244,0.00001257,0.000012,0.00001241,1738501],"204":[1598007600000,0.00001241,0.00001248,0.00001193,0.00001198,949002],"205":[1598011200000,0.00001198,0.0000125,0.00001163,0.00001223,1447104],"206":[1598014800000,0.00001224,0.00001224,0.00001201,0.00001201,438699],"207":[1598018400000,0.00001206,0.00001225,0.00001181,0.00001201,600442],"208":[1598022000000,0.00001199,0.00001209,0.00001198,0.00001207,268651],"209":[1598025600000,0.00001207,0.0000121,0.00001198,0.00001198,340484],"210":[1598029200000,0.00001197,0.00001201,0.00001179,0.00001193,487617],"211":[1598032800000,0.0000119,0.00001191,0.00001165,0.00001168,452266],"212":[1598036400000,0.00001168,0.00001176,0.00001165,0.00001168,448581],"213":[1598040000000,0.00001168,0.00001193,0.00001168,0.00001172,285002],"214":[1598043600000,0.00001172,0.00001175,0.0000111,0.00001136,1678873],"215":[1598047200000,0.00001138,0.00001164,0.00001137,0.00001159,162862],"216":[1598050800000,0.00001158,0.00001162,0.00001147,0.00001151,136752],"217":[1598054400000,0.00001147,0.00001151,0.00001108,0.00001132,687714],"218":[1598058000000,0.00001132,0.00001143,0.00001116,0.00001142,134947],"219":[1598061600000,0.00001142,0.00001145,0.00001136,0.00001139,82689],"220":[1598065200000,0.00001142,0.0000116,0.00001139,0.00001154,91283],"221":[1598068800000,0.00001154,0.00001164,0.00001153,0.00001162,43672],"222":[1598072400000,0.00001157,0.00001162,0.0000115,0.0000116,121304],"223":[1598076000000,0.0000116,0.0000117,0.00001157,0.0000117,363089],"224":[1598079600000,0.0000117,0.00001176,0.00001168,0.00001171,142591],"225":[1598083200000,0.00001174,0.0000118,0.00001166,0.00001166,171494],"226":[1598086800000,0.00001165,0.00001167,0.00001155,0.00001157,216100],"227":[1598090400000,0.00001155,0.00001172,0.00001155,0.00001168,178100],"228":[1598094000000,0.00001168,0.00001171,0.00001154,0.00001159,162288],"229":[1598097600000,0.00001158,0.00001162,0.00001154,0.0000116,67419],"230":[1598101200000,0.00001163,0.0000118,0.00001161,0.00001175,365593],"231":[1598104800000,0.00001176,0.00001185,0.00001169,0.00001174,257142],"232":[1598108400000,0.00001175,0.00001181,0.00001171,0.00001176,76503],"233":[1598112000000,0.00001177,0.0000118,0.00001163,0.00001167,216661],"234":[1598115600000,0.00001163,0.00001179,0.00001162,0.00001175,159010],"235":[1598119200000,0.00001176,0.00001179,0.00001174,0.00001174,60121],"236":[1598122800000,0.00001174,0.0000118,0.00001165,0.00001169,156452],"237":[1598126400000,0.00001169,0.0000118,0.00001159,0.00001162,140324],"238":[1598130000000,0.00001165,0.00001168,0.00001161,0.00001165,106871],"239":[1598133600000,0.00001165,0.00001181,0.00001165,0.0000118,88368],"240":[1598137200000,0.00001181,0.00001183,0.0000117,0.00001183,250608],"241":[1598140800000,0.00001183,0.00001185,0.00001177,0.00001179,99763],"242":[1598144400000,0.0000118,0.0000118,0.00001166,0.00001167,157997],"243":[1598148000000,0.00001169,0.00001174,0.00001166,0.00001168,42897],"244":[1598151600000,0.00001168,0.00001176,0.00001166,0.00001166,67884],"245":[1598155200000,0.00001169,0.00001171,0.00001156,0.00001162,151376],"246":[1598158800000,0.00001162,0.00001174,0.0000116,0.00001167,48579],"247":[1598162400000,0.00001166,0.00001166,0.00001147,0.00001153,294018],"248":[1598166000000,0.00001153,0.0000116,0.0000115,0.00001158,142439],"249":[1598169600000,0.00001161,0.00001163,0.00001158,0.00001159,75068],"250":[1598173200000,0.0000116,0.00001175,0.00001157,0.00001175,284797],"251":[1598176800000,0.00001176,0.00001177,0.00001158,0.00001158,253133],"252":[1598180400000,0.00001159,0.00001167,0.00001151,0.00001153,303799],"253":[1598184000000,0.00001154,0.00001154,0.00001138,0.00001146,644925],"254":[1598187600000,0.00001147,0.0000116,0.00001142,0.00001156,203749],"255":[1598191200000,0.00001155,0.00001155,0.00001148,0.00001149,68423],"256":[1598194800000,0.00001149,0.00001156,0.00001141,0.00001154,201348],"257":[1598198400000,0.00001152,0.00001162,0.00001146,0.00001149,90822],"258":[1598202000000,0.00001148,0.00001157,0.00001148,0.00001153,140553],"259":[1598205600000,0.00001152,0.00001159,0.0000115,0.00001157,38444],"260":[1598209200000,0.00001155,0.00001156,0.00001145,0.00001146,51240],"261":[1598212800000,0.00001146,0.00001148,0.0000114,0.00001148,67934],"262":[1598216400000,0.00001148,0.00001162,0.00001148,0.00001159,101326],"263":[1598220000000,0.00001159,0.00001159,0.00001153,0.00001157,15164],"264":[1598223600000,0.00001157,0.0000116,0.00001155,0.00001159,30295],"265":[1598227200000,0.0000116,0.00001162,0.0000115,0.00001151,43423],"266":[1598230800000,0.00001152,0.00001159,0.00001133,0.00001139,410665],"267":[1598234400000,0.00001142,0.00001149,0.0000114,0.00001149,95597],"268":[1598238000000,0.00001149,0.00001155,0.00001146,0.0000115,167529],"269":[1598241600000,0.00001151,0.00001152,0.00001146,0.00001151,108477],"270":[1598245200000,0.00001151,0.0000117,0.00001146,0.00001163,491628],"271":[1598248800000,0.00001162,0.00001169,0.00001157,0.00001167,153848],"272":[1598252400000,0.00001166,0.00001178,0.00001156,0.00001175,634645],"273":[1598256000000,0.00001175,0.0000119,0.00001172,0.00001188,502819],"274":[1598259600000,0.00001188,0.00001205,0.00001184,0.00001203,637230],"275":[1598263200000,0.00001202,0.0000121,0.00001192,0.00001193,449158],"276":[1598266800000,0.00001193,0.00001208,0.00001193,0.00001195,282551],"277":[1598270400000,0.00001195,0.00001199,0.00001164,0.00001183,640279],"278":[1598274000000,0.00001183,0.00001201,0.00001183,0.0000119,267518],"279":[1598277600000,0.00001193,0.00001195,0.00001184,0.00001184,170189],"280":[1598281200000,0.00001183,0.00001194,0.00001179,0.0000119,186909],"281":[1598284800000,0.0000119,0.00001208,0.00001189,0.00001199,1325840],"282":[1598288400000,0.00001198,0.0000124,0.00001192,0.00001234,1458011],"283":[1598292000000,0.00001239,0.00001242,0.00001189,0.00001194,2459033],"284":[1598295600000,0.00001195,0.000012,0.00001187,0.00001194,145200],"285":[1598299200000,0.00001195,0.00001199,0.00001189,0.00001194,212291],"286":[1598302800000,0.00001194,0.00001202,0.0000119,0.00001201,58548],"287":[1598306400000,0.00001197,0.00001204,0.00001192,0.00001194,171074],"288":[1598310000000,0.00001192,0.000012,0.00001189,0.000012,70062],"289":[1598313600000,0.00001199,0.00001204,0.00001194,0.00001197,102372],"290":[1598317200000,0.00001199,0.000012,0.0000119,0.00001194,99122],"291":[1598320800000,0.00001194,0.00001194,0.00001174,0.00001176,447940],"292":[1598324400000,0.00001174,0.00001192,0.00001173,0.00001192,271904],"293":[1598328000000,0.00001191,0.00001192,0.00001176,0.00001184,186150],"294":[1598331600000,0.00001183,0.00001185,0.00001173,0.00001182,271915],"295":[1598335200000,0.00001182,0.00001194,0.00001179,0.00001179,158181],"296":[1598338800000,0.0000118,0.00001183,0.00001172,0.00001176,287338],"297":[1598342400000,0.00001173,0.00001183,0.00001163,0.00001182,224336],"298":[1598346000000,0.00001184,0.00001188,0.00001171,0.00001181,167136],"299":[1598349600000,0.00001178,0.00001181,0.00001166,0.00001175,375047],"300":[1598353200000,0.00001173,0.00001221,0.00001171,0.00001202,1038858],"301":[1598356800000,0.00001201,0.00001201,0.00001176,0.00001176,558830],"302":[1598360400000,0.00001178,0.00001189,0.00001173,0.0000118,198407],"303":[1598364000000,0.00001179,0.00001189,0.00001174,0.00001186,287261],"304":[1598367600000,0.00001187,0.00001189,0.00001168,0.00001171,200257],"305":[1598371200000,0.00001171,0.00001186,0.00001168,0.00001175,220845],"306":[1598374800000,0.00001176,0.00001179,0.00001155,0.00001159,716037],"307":[1598378400000,0.00001162,0.00001183,0.0000115,0.00001182,450693],"308":[1598382000000,0.00001184,0.0000119,0.00001173,0.0000118,141477],"309":[1598385600000,0.00001181,0.00001183,0.00001163,0.00001178,94432],"310":[1598389200000,0.00001172,0.00001176,0.00001167,0.00001176,39980],"311":[1598392800000,0.00001176,0.00001183,0.00001172,0.00001182,44598],"312":[1598396400000,0.00001183,0.00001186,0.0000118,0.00001185,56211],"313":[1598400000000,0.00001185,0.00001186,0.00001171,0.00001175,54779],"314":[1598403600000,0.00001175,0.0000118,0.00001171,0.00001179,70461],"315":[1598407200000,0.0000118,0.0000119,0.0000116,0.00001173,327197],"316":[1598410800000,0.00001174,0.00001181,0.0000116,0.00001174,374128],"317":[1598414400000,0.00001173,0.00001179,0.00001171,0.00001174,137727],"318":[1598418000000,0.00001174,0.00001177,0.00001167,0.00001176,107373],"319":[1598421600000,0.00001176,0.00001176,0.0000117,0.00001174,86797],"320":[1598425200000,0.00001174,0.00001177,0.00001161,0.00001169,158967],"321":[1598428800000,0.00001167,0.00001174,0.00001147,0.00001169,278539],"322":[1598432400000,0.00001167,0.0000118,0.00001167,0.00001175,70517],"323":[1598436000000,0.00001174,0.0000119,0.00001173,0.00001187,293619],"324":[1598439600000,0.00001187,0.00001189,0.00001175,0.00001186,73425],"325":[1598443200000,0.00001184,0.00001184,0.00001167,0.00001172,269686],"326":[1598446800000,0.0000117,0.00001178,0.00001161,0.00001165,284592],"327":[1598450400000,0.00001165,0.00001171,0.0000116,0.0000117,163134],"328":[1598454000000,0.00001169,0.0000119,0.00001164,0.00001167,409656],"329":[1598457600000,0.00001167,0.00001172,0.00001161,0.00001166,417479],"330":[1598461200000,0.00001166,0.00001181,0.00001163,0.0000118,192167],"331":[1598464800000,0.00001178,0.00001185,0.0000117,0.00001175,164653],"332":[1598468400000,0.00001175,0.00001175,0.00001168,0.00001174,69948],"333":[1598472000000,0.00001171,0.00001171,0.00001164,0.00001166,142654],"334":[1598475600000,0.00001167,0.00001178,0.00001167,0.00001175,125896],"335":[1598479200000,0.00001175,0.00001175,0.00001166,0.00001173,50832],"336":[1598482800000,0.00001173,0.00001174,0.00001163,0.0000117,217189],"337":[1598486400000,0.00001171,0.00001183,0.00001171,0.00001181,21751],"338":[1598490000000,0.00001184,0.00001185,0.00001172,0.00001176,178044],"339":[1598493600000,0.00001177,0.00001182,0.00001172,0.00001179,163454],"340":[1598497200000,0.00001178,0.00001183,0.00001177,0.00001182,32207],"341":[1598500800000,0.00001182,0.00001183,0.00001171,0.00001175,159871],"342":[1598504400000,0.00001171,0.00001175,0.00001168,0.00001169,141270],"343":[1598508000000,0.00001172,0.00001179,0.00001168,0.00001169,106312],"344":[1598511600000,0.00001172,0.00001172,0.00001163,0.00001167,86256],"345":[1598515200000,0.00001165,0.00001173,0.00001162,0.00001168,172391],"346":[1598518800000,0.0000117,0.00001174,0.00001165,0.00001174,144928],"347":[1598522400000,0.00001174,0.00001179,0.00001169,0.00001175,118667],"348":[1598526000000,0.00001175,0.00001196,0.00001165,0.00001169,1379864],"349":[1598529600000,0.0000117,0.00001172,0.00001158,0.0000117,500874],"350":[1598533200000,0.0000117,0.00001172,0.00001154,0.00001166,313298],"351":[1598536800000,0.00001168,0.00001173,0.00001163,0.00001166,152344],"352":[1598540400000,0.00001167,0.00001175,0.0000116,0.00001167,116882],"353":[1598544000000,0.00001165,0.0000117,0.00001155,0.00001156,297043],"354":[1598547600000,0.00001158,0.00001165,0.00001145,0.00001149,800277],"355":[1598551200000,0.00001149,0.00001166,0.00001146,0.00001166,238354],"356":[1598554800000,0.00001164,0.00001171,0.00001149,0.00001153,344519],"357":[1598558400000,0.00001152,0.00001153,0.00001142,0.00001149,558338],"358":[1598562000000,0.00001151,0.00001153,0.00001143,0.00001152,108587],"359":[1598565600000,0.0000115,0.00001151,0.00001131,0.0000115,287655],"360":[1598569200000,0.00001146,0.00001149,0.00001142,0.00001143,205805],"361":[1598572800000,0.00001144,0.00001149,0.0000114,0.00001144,78184],"362":[1598576400000,0.00001145,0.00001157,0.00001142,0.00001156,138452],"363":[1598580000000,0.00001156,0.00001171,0.00001156,0.0000117,86593],"364":[1598583600000,0.00001168,0.00001171,0.00001157,0.00001157,86260],"365":[1598587200000,0.00001156,0.0000116,0.00001149,0.00001149,237238],"366":[1598590800000,0.0000115,0.00001154,0.00001146,0.00001151,376765],"367":[1598594400000,0.00001151,0.00001154,0.00001147,0.00001149,168730],"368":[1598598000000,0.00001153,0.00001156,0.00001142,0.00001145,283653],"369":[1598601600000,0.00001144,0.0000115,0.0000112,0.00001132,885068],"370":[1598605200000,0.00001135,0.00001137,0.00001126,0.00001128,186971],"371":[1598608800000,0.0000113,0.00001138,0.0000113,0.00001134,206633],"372":[1598612400000,0.00001133,0.00001143,0.00001132,0.00001135,84894],"373":[1598616000000,0.00001139,0.0000115,0.00001135,0.00001142,268539],"374":[1598619600000,0.00001142,0.00001153,0.00001132,0.00001137,621974],"375":[1598623200000,0.00001135,0.0000114,0.00001126,0.00001126,560966],"376":[1598626800000,0.00001131,0.00001148,0.00001123,0.00001146,585890],"377":[1598630400000,0.00001146,0.00001151,0.00001138,0.00001145,334764],"378":[1598634000000,0.00001149,0.0000115,0.00001137,0.00001137,145318],"379":[1598637600000,0.00001138,0.0000115,0.00001136,0.00001141,143341],"380":[1598641200000,0.00001143,0.00001144,0.00001137,0.00001144,180442],"381":[1598644800000,0.00001143,0.00001144,0.00001135,0.00001139,99665],"382":[1598648400000,0.0000114,0.00001143,0.00001132,0.00001138,152057],"383":[1598652000000,0.00001138,0.00001139,0.00001133,0.00001134,70627],"384":[1598655600000,0.00001134,0.00001145,0.00001134,0.00001143,99926],"385":[1598659200000,0.0000114,0.00001145,0.00001138,0.00001144,52024],"386":[1598662800000,0.00001143,0.00001145,0.00001139,0.00001144,100704],"387":[1598666400000,0.00001142,0.00001155,0.00001142,0.00001149,180635],"388":[1598670000000,0.0000115,0.00001154,0.00001149,0.00001149,57774],"389":[1598673600000,0.00001153,0.0000116,0.00001145,0.00001149,191302],"390":[1598677200000,0.00001149,0.00001155,0.00001145,0.00001146,105937],"391":[1598680800000,0.00001149,0.00001153,0.00001145,0.00001151,212140],"392":[1598684400000,0.0000115,0.00001151,0.00001145,0.00001149,184550],"393":[1598688000000,0.00001149,0.00001175,0.00001149,0.00001171,754620],"394":[1598691600000,0.00001172,0.00001174,0.00001166,0.00001168,277768],"395":[1598695200000,0.00001169,0.0000117,0.00001152,0.0000116,459700],"396":[1598698800000,0.0000116,0.00001163,0.00001149,0.00001159,246105],"397":[1598702400000,0.0000116,0.00001162,0.0000115,0.0000115,203728],"398":[1598706000000,0.0000115,0.00001154,0.00001145,0.0000115,273230],"399":[1598709600000,0.00001147,0.00001156,0.00001145,0.00001154,117601],"400":[1598713200000,0.00001151,0.00001176,0.00001146,0.00001169,931243],"401":[1598716800000,0.00001168,0.00001176,0.00001159,0.00001171,487259],"402":[1598720400000,0.00001171,0.00001176,0.0000117,0.00001174,312689],"403":[1598724000000,0.00001171,0.00001176,0.00001169,0.00001175,459343],"404":[1598727600000,0.00001174,0.00001202,0.00001172,0.00001198,3114897],"405":[1598731200000,0.00001198,0.000012,0.00001184,0.00001198,1160672],"406":[1598734800000,0.00001199,0.00001214,0.00001187,0.00001195,790424],"407":[1598738400000,0.00001193,0.00001194,0.00001181,0.00001183,74466],"408":[1598742000000,0.00001184,0.00001188,0.0000117,0.00001184,394522],"409":[1598745600000,0.00001184,0.00001186,0.00001177,0.00001178,41544],"410":[1598749200000,0.00001178,0.00001199,0.00001178,0.00001184,339819],"411":[1598752800000,0.00001183,0.00001188,0.00001178,0.00001186,65516],"412":[1598756400000,0.00001186,0.00001204,0.00001182,0.00001203,391482],"413":[1598760000000,0.000012,0.0000121,0.00001191,0.00001194,519902],"414":[1598763600000,0.00001193,0.00001194,0.00001182,0.00001194,203961],"415":[1598767200000,0.00001194,0.000012,0.0000118,0.0000118,361356],"416":[1598770800000,0.0000118,0.00001186,0.00001177,0.00001177,326985],"417":[1598774400000,0.00001177,0.0000118,0.00001172,0.00001177,187516],"418":[1598778000000,0.00001179,0.00001179,0.00001165,0.00001175,522997],"419":[1598781600000,0.00001172,0.00001181,0.00001171,0.00001177,67808],"420":[1598785200000,0.00001178,0.00001183,0.00001169,0.0000117,359380],"421":[1598788800000,0.00001174,0.00001177,0.00001167,0.00001168,322899],"422":[1598792400000,0.00001168,0.00001169,0.00001152,0.00001157,638491],"423":[1598796000000,0.00001156,0.00001165,0.00001154,0.00001163,108324],"424":[1598799600000,0.00001162,0.00001167,0.00001152,0.00001167,417522],"425":[1598803200000,0.00001166,0.00001169,0.0000115,0.00001152,226553],"426":[1598806800000,0.00001155,0.00001168,0.00001154,0.00001168,111762],"427":[1598810400000,0.00001168,0.0000117,0.00001163,0.00001166,119425],"428":[1598814000000,0.00001163,0.0000117,0.00001162,0.00001164,82590],"429":[1598817600000,0.00001164,0.0000117,0.0000116,0.0000116,67525],"430":[1598821200000,0.0000116,0.00001171,0.00001159,0.00001164,255301],"431":[1598824800000,0.00001166,0.00001169,0.00001163,0.00001168,40298],"432":[1598828400000,0.00001166,0.00001171,0.0000115,0.00001153,282324],"433":[1598832000000,0.00001153,0.00001165,0.00001153,0.00001162,59200],"434":[1598835600000,0.00001163,0.00001165,0.00001155,0.00001158,110635],"435":[1598839200000,0.00001158,0.0000116,0.00001153,0.00001157,73220],"436":[1598842800000,0.00001157,0.00001163,0.00001156,0.00001163,88708],"437":[1598846400000,0.00001159,0.0000117,0.00001155,0.00001163,113939],"438":[1598850000000,0.00001164,0.00001165,0.00001153,0.00001164,165713],"439":[1598853600000,0.00001162,0.00001166,0.00001157,0.0000116,250486],"440":[1598857200000,0.00001158,0.00001167,0.00001147,0.00001163,629172],"441":[1598860800000,0.00001163,0.00001192,0.00001163,0.00001172,1008567],"442":[1598864400000,0.00001172,0.00001182,0.00001163,0.0000118,83265],"443":[1598868000000,0.00001181,0.00001195,0.00001177,0.00001192,413537],"444":[1598871600000,0.00001192,0.00001192,0.0000117,0.00001181,174275],"445":[1598875200000,0.00001178,0.00001179,0.00001157,0.00001161,444106],"446":[1598878800000,0.00001161,0.00001163,0.00001156,0.0000116,257009],"447":[1598882400000,0.0000116,0.00001165,0.00001155,0.00001162,194130],"448":[1598886000000,0.00001162,0.00001167,0.00001151,0.00001153,254253],"449":[1598889600000,0.00001153,0.00001182,0.00001152,0.00001171,386948],"450":[1598893200000,0.00001171,0.00001178,0.00001166,0.00001169,349777],"451":[1598896800000,0.0000117,0.00001176,0.00001165,0.00001172,138134],"452":[1598900400000,0.0000117,0.00001177,0.00001165,0.00001172,266197],"453":[1598904000000,0.00001169,0.00001175,0.00001163,0.00001169,132444],"454":[1598907600000,0.00001168,0.00001172,0.0000116,0.0000117,139229],"455":[1598911200000,0.0000117,0.00001171,0.0000116,0.00001167,76073],"456":[1598914800000,0.00001166,0.0000117,0.00001163,0.00001169,40474],"457":[1598918400000,0.0000117,0.0000117,0.00001133,0.00001144,1284443],"458":[1598922000000,0.00001146,0.00001154,0.00001138,0.00001146,322343],"459":[1598925600000,0.00001145,0.00001153,0.00001145,0.00001147,182500],"460":[1598929200000,0.00001147,0.00001157,0.00001145,0.00001154,77758],"461":[1598932800000,0.00001152,0.00001155,0.00001137,0.0000115,451689],"462":[1598936400000,0.0000115,0.00001151,0.0000114,0.0000114,218725],"463":[1598940000000,0.00001141,0.00001156,0.00001127,0.00001137,1100700],"464":[1598943600000,0.00001136,0.00001146,0.0000113,0.00001135,1099708],"465":[1598947200000,0.00001133,0.00001142,0.00001129,0.00001138,329131],"466":[1598950800000,0.00001138,0.00001139,0.00001122,0.00001125,401462],"467":[1598954400000,0.00001128,0.00001133,0.00001118,0.00001126,223864],"468":[1598958000000,0.00001126,0.00001127,0.00001111,0.00001118,593431],"469":[1598961600000,0.0000112,0.00001122,0.00001092,0.00001104,2150793],"470":[1598965200000,0.00001102,0.0000111,0.00001097,0.0000111,680057],"471":[1598968800000,0.00001111,0.00001118,0.00001076,0.00001107,723571],"472":[1598972400000,0.00001107,0.0000111,0.00001082,0.00001087,628668],"473":[1598976000000,0.00001087,0.00001117,0.00001076,0.00001097,757983],"474":[1598979600000,0.00001097,0.00001117,0.00001096,0.00001115,204836],"475":[1598983200000,0.00001116,0.00001118,0.000011,0.00001105,289150],"476":[1598986800000,0.00001104,0.0000111,0.00001097,0.00001103,170835],"477":[1598990400000,0.00001103,0.00001106,0.0000109,0.00001091,454187],"478":[1598994000000,0.00001094,0.000011,0.00001089,0.00001089,149334],"479":[1598997600000,0.00001094,0.00001108,0.00001094,0.00001096,231599],"480":[1599001200000,0.00001096,0.00001099,0.00001086,0.00001095,247574],"481":[1599004800000,0.00001094,0.00001115,0.00001088,0.00001097,584183],"482":[1599008400000,0.00001097,0.00001097,0.00001075,0.00001083,826309],"483":[1599012000000,0.00001083,0.00001106,0.00001083,0.00001106,388253],"484":[1599015600000,0.00001105,0.00001113,0.00001086,0.00001091,607747],"485":[1599019200000,0.0000109,0.00001109,0.00001087,0.00001099,401308],"486":[1599022800000,0.00001099,0.00001104,0.00001095,0.00001098,171337],"487":[1599026400000,0.00001097,0.00001113,0.00001097,0.00001101,275166],"488":[1599030000000,0.00001102,0.00001109,0.00001096,0.00001105,188502],"489":[1599033600000,0.00001107,0.00001108,0.000011,0.00001108,314121],"490":[1599037200000,0.00001108,0.00001114,0.000011,0.00001112,268443],"491":[1599040800000,0.00001112,0.00001151,0.00001109,0.00001112,804007],"492":[1599044400000,0.00001109,0.00001117,0.0000107,0.00001112,1730564],"493":[1599048000000,0.0000111,0.0000113,0.00001095,0.00001113,405242],"494":[1599051600000,0.00001115,0.00001123,0.00001102,0.00001109,602711],"495":[1599055200000,0.00001111,0.00001125,0.00001106,0.00001116,175539],"496":[1599058800000,0.00001115,0.00001116,0.00001104,0.00001112,214132],"497":[1599062400000,0.00001113,0.00001127,0.00001105,0.0000111,437358],"498":[1599066000000,0.00001112,0.00001114,0.00001104,0.00001107,160932],"499":[1599069600000,0.00001106,0.00001107,0.00001103,0.00001107,41772],"level":"debug","message":"fetchOHLCV"}

kingkong404 commented 4 years ago

@bennyn apologies if the data is not in the best format. If follows the format:

//     [
//         1504541580000, // UTC timestamp in milliseconds, integer
//         4235.4,        // (O)pen price, float
//         4240.6,        // (H)ighest price, float
//         4230.0,        // (L)owest price, float
//         4230.7,        // (C)losing price, float
//         37.72941911    // (V)olume (in terms of the base currency), float
//     ],
bennycode commented 4 years ago

Thanks for providing this data.

I tried to reproduce your result of "63.476620248325204" when using SMMA:

import candles from '../test/fixtures/RSI/500-candles-WRX-BTC-1h.json';

// ...

for (const candle of Object.values(candles)) {
  const closingPrice = candle[4];
  rsi.update(closingPrice);
  // console.log('RSI', , rsi.getResult().valueOf());
  if (rsi.getResult().eq('63.476620248325204')) {
    console.log(new Date(candle[0]).toISOString());
    process.exit(0);
  }
}

Unfortunately this condition never turns true, so I am not getting the same results as you did.

Can you please check if I am holding it wrong? Here is a test case which imports your 500 candles and uses EMA to get a RSI result of "70". This fails too. What's the expected RSI after importing all 500 candles?

kingkong404 commented 4 years ago

Hey @bennyn on the data set I provided the RSI at the 500th candle should be around 44.6, but I believe when I pulled the data the 500th candle was still in progress, so it might be better to look at the 499th candle that had closed. Which should be around 48.8, 498th - 51.7, 497th - 50, 496th - 52

https://uk.tradingview.com/chart/WBgn29wN/ - 500th Candle was at 2020-09-02T13:00:00-05:00

image

Running the test case is a little beyond me, although I hope the image helps to see the surrounding values.

bennycode commented 4 years ago

Unfortunately I cannot view your chart. The website tells me:

Access Denied: Please ask the owner to enable chart layout sharing or to publish it by clicking the Publish Idea button.

I tested your candles with EMA and RSI interval 14 but with my current implementation I am getting:

Are you sure that TradingView uses EMA to calculate the RSI?

bennycode commented 4 years ago

I merged the feature to use EMA with RSI just now. I also added an isStable getter to the RSI class, so you can check if there are enough input values. Take in mind that getResult() throws now an error if there are not enough data points.

kingkong404 commented 4 years ago

Hey @bennyn, thanks for that I tested both the EMA and SMMA versions of the RSI and yes, you are right, it seems they still don't match up :/

Here is also a document on RSI from TradingView - although marketing could be out of sync with how the dev team has actually implemented it.

I'm a little lost as to why it's not working, potentially the EMA interval? Although here is more data this time on ETH/BTC from Binance, which should make testing easier.

https://www.tradingview.com/chart/?symbol=BINANCE%3AETHBTC <-- this should work ;)

and thanks again for all your help!

image

image

My code:

  calculateRSI(candles: ccxt.OHLCV[]) {

    const rsi = new RSI(14, EMA);

    candles.map((candle) => {
      const close = Big(candle[4]);
      rsi.update(close);
      if (rsi.isStable) {
        this.rsiArray.unshift(Number(rsi.getResult()));
      }
    });
    if (rsi.isStable) { 
      return Number(rsi.getResult());
    }
    return 0
  }

DATA SET {"0":[1597420800000,0.03719,0.037701,0.037051,0.037352,80037.749],"1":[1597424400000,0.037352,0.037391,0.037055,0.037331,29484.402],"2":[1597428000000,0.037334,0.03755,0.037316,0.037393,18244.696],"3":[1597431600000,0.03739,0.037516,0.037278,0.03735,22574.355],"4":[1597435200000,0.037349,0.037453,0.037189,0.037319,12495.575],"5":[1597438800000,0.037326,0.037345,0.037089,0.037222,8540.393],"6":[1597442400000,0.037225,0.037338,0.0371,0.037321,12056.502],"7":[1597446000000,0.037323,0.037402,0.037064,0.037254,11223.156],"8":[1597449600000,0.037254,0.037366,0.036399,0.036806,38691.855],"9":[1597453200000,0.036803,0.037019,0.036684,0.036993,13127.486],"10":[1597456800000,0.036993,0.037107,0.036903,0.036964,11266.199],"11":[1597460400000,0.036969,0.037008,0.036879,0.036942,8264.551],"12":[1597464000000,0.036942,0.037042,0.036812,0.036942,12086.416],"13":[1597467600000,0.036943,0.036951,0.036783,0.036927,11359.719],"14":[1597471200000,0.036929,0.036983,0.036827,0.036886,8341.807],"15":[1597474800000,0.036879,0.036909,0.03668,0.036751,10722.52],"16":[1597478400000,0.036757,0.03681,0.036121,0.036528,20816.759],"17":[1597482000000,0.036528,0.036765,0.036509,0.036658,11233.974],"18":[1597485600000,0.036657,0.036815,0.036609,0.036668,8219.547],"19":[1597489200000,0.036663,0.03674,0.036625,0.036656,6995.506],"20":[1597492800000,0.036658,0.036978,0.036507,0.036648,25036.926],"21":[1597496400000,0.036655,0.036768,0.036603,0.03662,16577.987],"22":[1597500000000,0.036619,0.036677,0.036403,0.036642,11350.029],"23":[1597503600000,0.036642,0.036826,0.036579,0.036748,10494.631],"24":[1597507200000,0.036753,0.036894,0.036624,0.036695,10182.833],"25":[1597510800000,0.036697,0.036765,0.036645,0.036682,6978.655],"26":[1597514400000,0.036685,0.036729,0.03657,0.036694,5794.257],"27":[1597518000000,0.036684,0.03671,0.036482,0.036495,7668.413],"28":[1597521600000,0.036496,0.036612,0.036402,0.036421,9754.595],"29":[1597525200000,0.036431,0.036682,0.035789,0.036377,26667.687],"30":[1597528800000,0.036381,0.036483,0.036306,0.03641,12389.032],"31":[1597532400000,0.036413,0.0365,0.036335,0.036472,4873.389],"32":[1597536000000,0.036478,0.036537,0.036147,0.03616,8067.148],"33":[1597539600000,0.036164,0.036231,0.03582,0.036167,15908.297],"34":[1597543200000,0.036167,0.036192,0.0359,0.035926,8217.314],"35":[1597546800000,0.035927,0.036085,0.035721,0.035773,11717.19],"36":[1597550400000,0.035775,0.036046,0.035679,0.035993,12134.174],"37":[1597554000000,0.035995,0.036073,0.03596,0.03603,6694.576],"38":[1597557600000,0.036025,0.036051,0.035939,0.036034,6714.786],"39":[1597561200000,0.036036,0.036051,0.03592,0.035977,8637.81],"40":[1597564800000,0.035976,0.03606,0.035894,0.03602,9250.853],"41":[1597568400000,0.036023,0.036057,0.035899,0.035974,9622.677],"42":[1597572000000,0.03597,0.036003,0.035825,0.035914,9342.006],"43":[1597575600000,0.035911,0.035931,0.0355,0.035553,18505.33],"44":[1597579200000,0.03556,0.035679,0.035254,0.035643,21702.133],"45":[1597582800000,0.035644,0.035819,0.035557,0.035778,11342.055],"46":[1597586400000,0.035783,0.035933,0.035756,0.035879,7644.322],"47":[1597590000000,0.03588,0.03638,0.035818,0.0363,13857.832],"48":[1597593600000,0.0363,0.036754,0.0363,0.036608,18529.503],"49":[1597597200000,0.036611,0.036696,0.036218,0.036375,8851.634],"50":[1597600800000,0.036386,0.03648,0.036315,0.036387,4617.521],"51":[1597604400000,0.036388,0.036396,0.036246,0.036327,6995.961],"52":[1597608000000,0.036325,0.036403,0.036183,0.036336,6697.945],"53":[1597611600000,0.03634,0.036493,0.036277,0.03639,7150.917],"54":[1597615200000,0.036384,0.036443,0.036264,0.036395,7733.441],"55":[1597618800000,0.036392,0.036523,0.036254,0.036408,6633.525],"56":[1597622400000,0.036408,0.036467,0.03632,0.036349,6865.654],"57":[1597626000000,0.036344,0.03635,0.036028,0.036127,8050.325],"58":[1597629600000,0.036121,0.036158,0.035796,0.035928,9566.879],"59":[1597633200000,0.03593,0.036009,0.03574,0.035933,7036.674],"60":[1597636800000,0.035937,0.035939,0.035734,0.035776,6679.681],"61":[1597640400000,0.035776,0.036,0.035701,0.035752,7323.568],"62":[1597644000000,0.035751,0.035997,0.035673,0.035911,7080.742],"63":[1597647600000,0.035913,0.035986,0.03578,0.035881,6570.351],"64":[1597651200000,0.035879,0.036196,0.03585,0.036117,11146.334],"65":[1597654800000,0.036116,0.036159,0.035923,0.035925,6518.39],"66":[1597658400000,0.035925,0.036066,0.035834,0.035904,8394.229],"67":[1597662000000,0.035906,0.035988,0.035828,0.03595,9911.087],"68":[1597665600000,0.035949,0.036173,0.035733,0.03587,13562.814],"69":[1597669200000,0.035868,0.036028,0.035367,0.03545,45972.909],"70":[1597672800000,0.03545,0.03553,0.03523,0.035456,26214.414],"71":[1597676400000,0.035461,0.035528,0.034888,0.035502,28748.325],"72":[1597680000000,0.035502,0.035867,0.035461,0.035511,29273.507],"73":[1597683600000,0.035511,0.035731,0.035484,0.035661,14230.626],"74":[1597687200000,0.035662,0.035707,0.035424,0.035439,12305.448],"75":[1597690800000,0.035433,0.035591,0.035393,0.035478,7367.455],"76":[1597694400000,0.035481,0.035632,0.035468,0.03554,5934.658],"77":[1597698000000,0.035546,0.035644,0.035397,0.035589,4966.754],"78":[1597701600000,0.035587,0.035608,0.035359,0.035371,9711.415],"79":[1597705200000,0.03537,0.035428,0.034942,0.03507,17101.811],"80":[1597708800000,0.03507,0.035195,0.034998,0.035099,9477.707],"81":[1597712400000,0.0351,0.0351,0.034775,0.03485,9785.769],"82":[1597716000000,0.03485,0.035028,0.034756,0.035006,7945.724],"83":[1597719600000,0.035004,0.035004,0.034847,0.034956,8512.355],"84":[1597723200000,0.034954,0.034995,0.03482,0.034969,8861.202],"85":[1597726800000,0.03497,0.035032,0.034854,0.035027,7859.073],"86":[1597730400000,0.035026,0.035117,0.034923,0.035102,10958.914],"87":[1597734000000,0.035107,0.035108,0.035002,0.03503,8773.737],"88":[1597737600000,0.035029,0.03516,0.035003,0.035159,9081.685],"89":[1597741200000,0.035159,0.035167,0.035031,0.035119,9080.491],"90":[1597744800000,0.035113,0.035176,0.035031,0.035106,8169.472],"91":[1597748400000,0.035102,0.035201,0.03507,0.035099,11240.419],"92":[1597752000000,0.035093,0.035185,0.035049,0.035063,13868.224],"93":[1597755600000,0.035059,0.035142,0.034867,0.035048,16672.003],"94":[1597759200000,0.035047,0.035445,0.03495,0.03537,32910.824],"95":[1597762800000,0.03537,0.035551,0.03517,0.035201,15125.555],"96":[1597766400000,0.035203,0.035447,0.035091,0.035347,14189.143],"97":[1597770000000,0.035349,0.035351,0.035245,0.035313,9156.588],"98":[1597773600000,0.03531,0.035421,0.035281,0.035319,8797.938],"99":[1597777200000,0.03532,0.035506,0.035318,0.035363,11231.885],"100":[1597780800000,0.035363,0.035645,0.035363,0.035538,11265.871],"101":[1597784400000,0.035539,0.035554,0.035392,0.035409,7376.229],"102":[1597788000000,0.035409,0.035481,0.035244,0.035297,10129.711],"103":[1597791600000,0.035302,0.035373,0.03519,0.03532,11994.517],"104":[1597795200000,0.035319,0.035428,0.035206,0.035414,11461.747],"105":[1597798800000,0.035422,0.035501,0.035334,0.035351,9783.157],"106":[1597802400000,0.035361,0.035406,0.035249,0.035299,8698.317],"107":[1597806000000,0.0353,0.035394,0.035091,0.035113,13034.501],"108":[1597809600000,0.035113,0.035216,0.034859,0.035061,21985.793],"109":[1597813200000,0.035057,0.035104,0.034795,0.03488,17920.421],"110":[1597816800000,0.034879,0.034942,0.034565,0.034815,23118.375],"111":[1597820400000,0.034815,0.034965,0.034755,0.034962,10432.051],"112":[1597824000000,0.03496,0.03504,0.034891,0.035,12982.149],"113":[1597827600000,0.035008,0.035173,0.034992,0.035061,11000.737],"114":[1597831200000,0.035063,0.035081,0.034812,0.034936,9567.475],"115":[1597834800000,0.03494,0.035045,0.034847,0.034875,8216.597],"116":[1597838400000,0.034875,0.034981,0.03475,0.034776,9255.674],"117":[1597842000000,0.034765,0.034902,0.034678,0.034763,9903.117],"118":[1597845600000,0.034757,0.034917,0.034736,0.03478,9952.112],"119":[1597849200000,0.034773,0.034979,0.034683,0.034928,11933.614],"120":[1597852800000,0.034927,0.035017,0.034404,0.034678,18648.153],"121":[1597856400000,0.034678,0.034717,0.034501,0.034653,9509.675],"122":[1597860000000,0.034649,0.034657,0.03427,0.034475,15195.169],"123":[1597863600000,0.034474,0.034549,0.033952,0.033989,24971.795],"124":[1597867200000,0.033982,0.034509,0.033842,0.034509,19071.542],"125":[1597870800000,0.034507,0.034768,0.034366,0.034604,8578.998],"126":[1597874400000,0.034604,0.034767,0.03456,0.034682,7269.62],"127":[1597878000000,0.03468,0.034792,0.034547,0.034667,8123.697],"128":[1597881600000,0.034666,0.035135,0.034665,0.034939,17421.923],"129":[1597885200000,0.034943,0.035068,0.03488,0.0349,8794.529],"130":[1597888800000,0.034896,0.034945,0.034737,0.034762,9041.956],"131":[1597892400000,0.034769,0.034867,0.034687,0.034787,6813.509],"132":[1597896000000,0.034788,0.034803,0.034536,0.034589,9802.042],"133":[1597899600000,0.034589,0.034617,0.034447,0.034563,8933.303],"134":[1597903200000,0.034562,0.034758,0.034453,0.034668,9912.852],"135":[1597906800000,0.034666,0.034708,0.034472,0.034546,11720.589],"136":[1597910400000,0.034546,0.034645,0.034479,0.034623,9527.089],"137":[1597914000000,0.034625,0.03485,0.034605,0.034775,7193.742],"138":[1597917600000,0.034773,0.034791,0.034664,0.034772,11507.469],"139":[1597921200000,0.034773,0.034865,0.034608,0.034813,10740.88],"140":[1597924800000,0.034817,0.034817,0.03471,0.034722,13476.073],"141":[1597928400000,0.034722,0.034903,0.03471,0.034892,15668.417],"142":[1597932000000,0.034899,0.035027,0.03483,0.03501,16312.6],"143":[1597935600000,0.035012,0.035098,0.034909,0.035025,21048.019],"144":[1597939200000,0.035025,0.035231,0.035003,0.035127,23160.607],"145":[1597942800000,0.035121,0.0352,0.035013,0.035014,16572.863],"146":[1597946400000,0.035012,0.035125,0.034923,0.035103,13766.066],"147":[1597950000000,0.035104,0.03513,0.034952,0.034977,10995.487],"148":[1597953600000,0.034977,0.035104,0.034967,0.035078,9243.084],"149":[1597957200000,0.035078,0.035274,0.035075,0.035187,10623.425],"150":[1597960800000,0.035183,0.03525,0.035025,0.035061,12596.925],"151":[1597964400000,0.035053,0.03512,0.034987,0.035085,10015.533],"152":[1597968000000,0.035088,0.03525,0.035052,0.035109,16005.698],"153":[1597971600000,0.035107,0.03512,0.034777,0.034863,11979.044],"154":[1597975200000,0.034863,0.034948,0.034746,0.034809,16468.989],"155":[1597978800000,0.034809,0.03507,0.034755,0.035049,15491.7],"156":[1597982400000,0.035049,0.0351,0.034954,0.034974,14069.081],"157":[1597986000000,0.034973,0.03507,0.03492,0.034936,7886.217],"158":[1597989600000,0.034937,0.034992,0.03492,0.034928,9783.135],"159":[1597993200000,0.034925,0.035009,0.03483,0.03487,10981.168],"160":[1597996800000,0.03487,0.03491,0.03468,0.034789,15211.856],"161":[1598000400000,0.034789,0.034843,0.03468,0.034688,11002.365],"162":[1598004000000,0.034683,0.03475,0.03452,0.03472,18967.098],"163":[1598007600000,0.03472,0.034754,0.034554,0.034596,12214.818],"164":[1598011200000,0.034596,0.03468,0.034327,0.034584,21510.754],"165":[1598014800000,0.034584,0.034672,0.034369,0.034374,13876.808],"166":[1598018400000,0.034375,0.03465,0.034339,0.034533,14127.887],"167":[1598022000000,0.034538,0.034642,0.034414,0.034489,11246.085],"168":[1598025600000,0.034492,0.034614,0.034338,0.034362,13732.496],"169":[1598029200000,0.034361,0.03459,0.034304,0.034463,14492.656],"170":[1598032800000,0.034465,0.034484,0.03394,0.034087,30327.448],"171":[1598036400000,0.034087,0.034273,0.03405,0.034066,16020.893],"172":[1598040000000,0.034066,0.034305,0.03399,0.034014,15986.913],"173":[1598043600000,0.03401,0.03408,0.033491,0.033688,31693.543],"174":[1598047200000,0.033687,0.03404,0.03363,0.033723,15476.939],"175":[1598050800000,0.033717,0.03387,0.0335,0.033645,16979.44],"176":[1598054400000,0.033644,0.033656,0.033322,0.033398,29387.634],"177":[1598058000000,0.033399,0.033659,0.033342,0.033622,14346.171],"178":[1598061600000,0.033622,0.033777,0.03357,0.033616,9708.389],"179":[1598065200000,0.033616,0.03372,0.033491,0.033591,11012.209],"180":[1598068800000,0.03359,0.033595,0.033367,0.033453,10030.392],"181":[1598072400000,0.033452,0.033663,0.033451,0.033658,7968.524],"182":[1598076000000,0.03366,0.033912,0.033655,0.033912,17098.167],"183":[1598079600000,0.033911,0.03393,0.033708,0.033782,10373.411],"184":[1598083200000,0.033782,0.03402,0.03375,0.033906,14600.873],"185":[1598086800000,0.033906,0.033927,0.033797,0.033858,8409.145],"186":[1598090400000,0.033866,0.03395,0.033777,0.033791,9378.592],"187":[1598094000000,0.033792,0.033806,0.033621,0.033734,10025.825],"188":[1598097600000,0.033733,0.0339,0.033712,0.033822,12761.136],"189":[1598101200000,0.033829,0.033861,0.033612,0.033744,9594.274],"190":[1598104800000,0.033743,0.03376,0.033591,0.033704,10388.011],"191":[1598108400000,0.033704,0.033823,0.033655,0.0337,13697.544],"192":[1598112000000,0.033699,0.033749,0.033604,0.033699,9953.583],"193":[1598115600000,0.033699,0.03372,0.03359,0.033696,9421.057],"194":[1598119200000,0.033697,0.03375,0.03363,0.033667,10320.196],"195":[1598122800000,0.033667,0.033686,0.033573,0.033587,8866.431],"196":[1598126400000,0.033589,0.033599,0.033452,0.033508,11440.459],"197":[1598130000000,0.033508,0.033742,0.033482,0.03373,6630.712],"198":[1598133600000,0.033731,0.033812,0.03365,0.033707,10591.678],"199":[1598137200000,0.033708,0.033974,0.03366,0.033884,10227.211],"200":[1598140800000,0.033885,0.03399,0.033745,0.03378,11966.916],"201":[1598144400000,0.033778,0.033821,0.033736,0.033791,6043.388],"202":[1598148000000,0.033794,0.033802,0.03366,0.03369,7265.645],"203":[1598151600000,0.033689,0.033716,0.033552,0.033609,8200.11],"204":[1598155200000,0.033608,0.03363,0.033522,0.033537,6985.4],"205":[1598158800000,0.033537,0.033607,0.033522,0.033593,6502.454],"206":[1598162400000,0.033592,0.033799,0.033583,0.033725,8374.791],"207":[1598166000000,0.033717,0.033767,0.03363,0.033651,8301.859],"208":[1598169600000,0.033652,0.03369,0.033581,0.033629,7447.892],"209":[1598173200000,0.03363,0.03369,0.033622,0.033643,6516.739],"210":[1598176800000,0.033641,0.033657,0.033478,0.033518,12387.542],"211":[1598180400000,0.033529,0.033621,0.033274,0.033308,12673.755],"212":[1598184000000,0.033308,0.0335,0.03327,0.033474,9515.565],"213":[1598187600000,0.033477,0.033651,0.03339,0.033547,13138.793],"214":[1598191200000,0.033546,0.033562,0.033459,0.033536,8519.501],"215":[1598194800000,0.033533,0.033711,0.03349,0.033693,9423.268],"216":[1598198400000,0.033694,0.03372,0.033502,0.033515,7750.712],"217":[1598202000000,0.033519,0.033567,0.033459,0.033516,6740.431],"218":[1598205600000,0.033513,0.033618,0.033467,0.033599,8036.904],"219":[1598209200000,0.033594,0.033736,0.033511,0.033713,6891.478],"220":[1598212800000,0.033714,0.033755,0.033638,0.033675,7847.597],"221":[1598216400000,0.033675,0.033755,0.033627,0.033701,6848.673],"222":[1598220000000,0.033704,0.033741,0.03354,0.033585,7600.496],"223":[1598223600000,0.033585,0.03365,0.033523,0.033541,4993.11],"224":[1598227200000,0.033542,0.033575,0.033436,0.033529,8160.697],"225":[1598230800000,0.033529,0.03357,0.033454,0.03348,7927.099],"226":[1598234400000,0.033481,0.033646,0.033468,0.033578,7687.385],"227":[1598238000000,0.033574,0.033728,0.033549,0.033655,9254.426],"228":[1598241600000,0.033651,0.033681,0.033585,0.033608,5391.421],"229":[1598245200000,0.033606,0.033704,0.033556,0.033677,5571.831],"230":[1598248800000,0.03368,0.033819,0.033625,0.03369,12197.712],"231":[1598252400000,0.03369,0.033906,0.033682,0.033889,11791.95],"232":[1598256000000,0.03389,0.03448,0.033883,0.034359,27174.385],"233":[1598259600000,0.034359,0.034416,0.034291,0.034391,11608.777],"234":[1598263200000,0.03439,0.034432,0.03432,0.034417,10505.655],"235":[1598266800000,0.034417,0.034589,0.034417,0.034507,14890.393],"236":[1598270400000,0.034507,0.034573,0.034417,0.034427,11932.933],"237":[1598274000000,0.034429,0.034589,0.034427,0.034479,10110.408],"238":[1598277600000,0.034479,0.034498,0.034236,0.034293,14485.431],"239":[1598281200000,0.034291,0.034362,0.034165,0.034261,11916.7],"240":[1598284800000,0.034262,0.034431,0.034231,0.03441,10925.767],"241":[1598288400000,0.034412,0.034419,0.034294,0.034319,7729.678],"242":[1598292000000,0.034321,0.034375,0.03415,0.034234,9361.996],"243":[1598295600000,0.034236,0.034371,0.03403,0.034335,12904.792],"244":[1598299200000,0.03434,0.034404,0.034237,0.034243,7120.389],"245":[1598302800000,0.034239,0.03468,0.034227,0.034596,13413.963],"246":[1598306400000,0.0346,0.034706,0.034559,0.034625,11901.279],"247":[1598310000000,0.034622,0.034808,0.03456,0.034704,14592.564],"248":[1598313600000,0.034704,0.034775,0.034485,0.03453,11002.78],"249":[1598317200000,0.034529,0.034587,0.03449,0.034518,7060.318],"250":[1598320800000,0.034519,0.034524,0.034327,0.034368,10365.074],"251":[1598324400000,0.034367,0.03444,0.034345,0.034402,9577.718],"252":[1598328000000,0.034398,0.034468,0.034323,0.034415,7795.749],"253":[1598331600000,0.034417,0.03445,0.034315,0.034323,7739.001],"254":[1598335200000,0.034322,0.034347,0.034127,0.034212,14215.033],"255":[1598338800000,0.034212,0.034212,0.03395,0.034112,14643.009],"256":[1598342400000,0.034114,0.034128,0.033836,0.034016,17866.681],"257":[1598346000000,0.034015,0.034161,0.03399,0.034084,11763.382],"258":[1598349600000,0.034084,0.03425,0.034024,0.03418,11469.371],"259":[1598353200000,0.034186,0.034207,0.03402,0.03403,8730.147],"260":[1598356800000,0.03403,0.03405,0.03384,0.033874,20267.448],"261":[1598360400000,0.033874,0.034117,0.03384,0.034056,16234.443],"262":[1598364000000,0.034056,0.034056,0.033694,0.033713,23255.009],"263":[1598367600000,0.03371,0.033845,0.033517,0.03377,20628.402],"264":[1598371200000,0.033767,0.033842,0.032922,0.033126,35367.035],"265":[1598374800000,0.033125,0.033295,0.032831,0.033271,28742.739],"266":[1598378400000,0.033269,0.033802,0.033187,0.033645,34551.903],"267":[1598382000000,0.033642,0.03377,0.033556,0.033598,15783.489],"268":[1598385600000,0.033601,0.03375,0.03346,0.033534,12463.887],"269":[1598389200000,0.033534,0.033693,0.03351,0.033522,7796.616],"270":[1598392800000,0.033523,0.033758,0.033519,0.033695,10291.599],"271":[1598396400000,0.033696,0.03385,0.03363,0.033836,10908.913],"272":[1598400000000,0.033836,0.033839,0.033556,0.033613,13878.162],"273":[1598403600000,0.033612,0.033869,0.033607,0.033742,7700.442],"274":[1598407200000,0.033741,0.03401,0.033727,0.033982,11946.425],"275":[1598410800000,0.033984,0.03402,0.033879,0.033984,8866.537],"276":[1598414400000,0.033984,0.034029,0.033895,0.033928,8851.151],"277":[1598418000000,0.033929,0.034008,0.033876,0.033895,10134.868],"278":[1598421600000,0.033894,0.033901,0.033614,0.033631,11022.166],"279":[1598425200000,0.033632,0.033712,0.033572,0.03361,11801.131],"280":[1598428800000,0.033612,0.033757,0.03355,0.033622,11166.333],"281":[1598432400000,0.033625,0.033732,0.033551,0.033555,12869.448],"282":[1598436000000,0.033555,0.033719,0.033555,0.033578,10641.768],"283":[1598439600000,0.033579,0.033711,0.03357,0.033611,10560.51],"284":[1598443200000,0.033611,0.033727,0.03351,0.033568,15652.464],"285":[1598446800000,0.033568,0.033825,0.033502,0.033723,14988.737],"286":[1598450400000,0.033714,0.0339,0.033713,0.033759,18562.349],"287":[1598454000000,0.033759,0.034,0.03375,0.03397,20293.336],"288":[1598457600000,0.03397,0.034172,0.033872,0.033899,16472.011],"289":[1598461200000,0.033899,0.033939,0.033831,0.033895,8801.931],"290":[1598464800000,0.033898,0.033977,0.033826,0.033845,9507.561],"291":[1598468400000,0.033845,0.033896,0.0337,0.03377,8865.145],"292":[1598472000000,0.03377,0.03385,0.033734,0.033844,6617.911],"293":[1598475600000,0.033844,0.033992,0.03381,0.033824,6989.157],"294":[1598479200000,0.033823,0.03384,0.033691,0.033703,6338.883],"295":[1598482800000,0.033711,0.033774,0.03363,0.033662,8500.106],"296":[1598486400000,0.033662,0.0339,0.033644,0.03388,8800.906],"297":[1598490000000,0.033883,0.033884,0.033792,0.03382,10095.961],"298":[1598493600000,0.033818,0.03384,0.033694,0.033704,10566.288],"299":[1598497200000,0.033704,0.03377,0.03369,0.033736,6847.044],"300":[1598500800000,0.033739,0.033822,0.0337,0.033703,6207.943],"301":[1598504400000,0.033702,0.033745,0.033561,0.033619,10353.557],"302":[1598508000000,0.033619,0.03388,0.033618,0.033816,10808.776],"303":[1598511600000,0.033815,0.033895,0.03379,0.033834,7817.951],"304":[1598515200000,0.033832,0.033832,0.033696,0.033724,9076.764],"305":[1598518800000,0.033722,0.03393,0.033657,0.033886,11589.059],"306":[1598522400000,0.033886,0.03395,0.03375,0.03378,10577.486],"307":[1598526000000,0.033781,0.03387,0.033725,0.033772,10680.886],"308":[1598529600000,0.033772,0.034008,0.03372,0.03396,14580.146],"309":[1598533200000,0.03396,0.03426,0.0339,0.03408,31648.656],"310":[1598536800000,0.034076,0.034147,0.03381,0.033876,22963.349],"311":[1598540400000,0.033875,0.033964,0.033853,0.033893,8265.08],"312":[1598544000000,0.033893,0.034028,0.033525,0.033549,18199.851],"313":[1598547600000,0.033548,0.033735,0.03328,0.033687,31918.496],"314":[1598551200000,0.033686,0.033886,0.033667,0.033791,16254.945],"315":[1598554800000,0.033788,0.033797,0.033572,0.033608,7950.846],"316":[1598558400000,0.033601,0.03379,0.033562,0.033708,8528.671],"317":[1598562000000,0.033708,0.033883,0.03369,0.033882,5962.019],"318":[1598565600000,0.033884,0.0339,0.033652,0.033654,6789.451],"319":[1598569200000,0.033655,0.03388,0.033655,0.03383,8768.591],"320":[1598572800000,0.033829,0.033832,0.03366,0.033818,10223.068],"321":[1598576400000,0.03382,0.03401,0.033775,0.033971,10549.407],"322":[1598580000000,0.03398,0.03402,0.03389,0.033949,7885.274],"323":[1598583600000,0.03395,0.034096,0.03395,0.03404,9289.16],"324":[1598587200000,0.034037,0.034075,0.033982,0.034069,6719.816],"325":[1598590800000,0.034071,0.03411,0.033966,0.034058,10504.847],"326":[1598594400000,0.034063,0.03423,0.033979,0.034192,11612.187],"327":[1598598000000,0.034192,0.034226,0.034004,0.034032,10026.896],"328":[1598601600000,0.034033,0.0341,0.033993,0.034003,8505.183],"329":[1598605200000,0.034005,0.03425,0.034,0.034237,13264.834],"330":[1598608800000,0.034238,0.03426,0.034142,0.034222,9786.519],"331":[1598612400000,0.034222,0.03438,0.034162,0.034313,14060.391],"332":[1598616000000,0.034317,0.034328,0.03414,0.03419,13662.121],"333":[1598619600000,0.034194,0.034249,0.03415,0.034221,7671.443],"334":[1598623200000,0.034221,0.03432,0.034175,0.034225,14730.93],"335":[1598626800000,0.034222,0.034507,0.034213,0.034364,15907.799],"336":[1598630400000,0.034366,0.03447,0.03432,0.034358,12650.612],"337":[1598634000000,0.034358,0.034427,0.03424,0.034303,12347.733],"338":[1598637600000,0.034304,0.034408,0.034264,0.034372,12415.11],"339":[1598641200000,0.034372,0.034522,0.034366,0.034432,8281.162],"340":[1598644800000,0.034433,0.034435,0.034274,0.034274,9489.297],"341":[1598648400000,0.034275,0.03441,0.034245,0.034311,6462.34],"342":[1598652000000,0.034313,0.034333,0.034107,0.034187,7127.425],"343":[1598655600000,0.034187,0.034358,0.03417,0.034282,10635.066],"344":[1598659200000,0.034282,0.034313,0.034185,0.034269,7959.353],"345":[1598662800000,0.034269,0.034275,0.0342,0.03423,5793.167],"346":[1598666400000,0.03423,0.034278,0.034186,0.034231,5400.203],"347":[1598670000000,0.034232,0.034339,0.034175,0.034291,5523.933],"348":[1598673600000,0.03429,0.034398,0.034257,0.034331,6758.257],"349":[1598677200000,0.034335,0.034476,0.034335,0.034408,6722.014],"350":[1598680800000,0.034411,0.03468,0.034403,0.034645,11693.404],"351":[1598684400000,0.034645,0.03494,0.034602,0.034903,15340.772],"352":[1598688000000,0.034902,0.03494,0.03479,0.034882,11991.46],"353":[1598691600000,0.034885,0.03496,0.034825,0.034905,10415.377],"354":[1598695200000,0.034906,0.03493,0.034709,0.034709,9775.188],"355":[1598698800000,0.034708,0.0348,0.034681,0.034747,8043.435],"356":[1598702400000,0.034747,0.034893,0.034735,0.034783,6456.623],"357":[1598706000000,0.034786,0.034813,0.03461,0.034658,8784.59],"358":[1598709600000,0.034659,0.0348,0.03463,0.034759,7582.419],"359":[1598713200000,0.034759,0.035013,0.034754,0.034992,14076.011],"360":[1598716800000,0.034992,0.035051,0.03491,0.03497,13332.461],"361":[1598720400000,0.034973,0.03504,0.034887,0.0349,13495.062],"362":[1598724000000,0.0349,0.035058,0.034876,0.03501,9184.751],"363":[1598727600000,0.035011,0.03512,0.03493,0.034958,12018.288],"364":[1598731200000,0.034957,0.035197,0.034957,0.035189,10320.595],"365":[1598734800000,0.03519,0.035212,0.03507,0.035158,5846.402],"366":[1598738400000,0.035158,0.035168,0.03486,0.034894,11476.712],"367":[1598742000000,0.034894,0.034998,0.034725,0.034767,11735.747],"368":[1598745600000,0.034767,0.0349,0.034751,0.034883,12936.127],"369":[1598749200000,0.03488,0.035061,0.034853,0.034957,18917.904],"370":[1598752800000,0.03496,0.035,0.03479,0.03488,11882.89],"371":[1598756400000,0.034879,0.034941,0.034815,0.034868,10388.223],"372":[1598760000000,0.034868,0.034914,0.0348,0.034869,12564.567],"373":[1598763600000,0.034869,0.034922,0.03481,0.034844,9942.638],"374":[1598767200000,0.034843,0.034931,0.034825,0.034872,9163.189],"375":[1598770800000,0.034871,0.03504,0.03485,0.034972,9085.418],"376":[1598774400000,0.034971,0.03503,0.034869,0.034871,12255.307],"377":[1598778000000,0.034871,0.034995,0.034865,0.034951,9174.991],"378":[1598781600000,0.034957,0.034971,0.034875,0.034914,9389.076],"379":[1598785200000,0.034913,0.035098,0.03489,0.035045,14496.52],"380":[1598788800000,0.035045,0.035185,0.035,0.035109,16164.667],"381":[1598792400000,0.035109,0.035675,0.035108,0.035584,31658.168],"382":[1598796000000,0.035595,0.035782,0.035481,0.035687,18949.016],"383":[1598799600000,0.035687,0.03593,0.03561,0.03588,25862.097],"384":[1598803200000,0.035885,0.036343,0.035801,0.036301,27355.778],"385":[1598806800000,0.036297,0.036487,0.036232,0.036403,29257.346],"386":[1598810400000,0.036406,0.036626,0.036297,0.036626,15626.723],"387":[1598814000000,0.036625,0.036718,0.036481,0.036509,15693.083],"388":[1598817600000,0.036509,0.03657,0.036152,0.03634,19424.673],"389":[1598821200000,0.03634,0.0365,0.036252,0.036343,12096.502],"390":[1598824800000,0.036346,0.03642,0.03625,0.036358,16226.217],"391":[1598828400000,0.036359,0.036702,0.036358,0.036626,21831.589],"392":[1598832000000,0.036622,0.036714,0.036398,0.036426,17885.833],"393":[1598835600000,0.036429,0.03654,0.03629,0.036508,12980.62],"394":[1598839200000,0.036511,0.03656,0.03642,0.03643,10344.17],"395":[1598842800000,0.036427,0.036496,0.036321,0.036392,10621.556],"396":[1598846400000,0.036393,0.03656,0.036381,0.036413,11632.266],"397":[1598850000000,0.036413,0.036469,0.036214,0.03625,12277.537],"398":[1598853600000,0.03625,0.036325,0.03608,0.036322,14291.921],"399":[1598857200000,0.03632,0.036325,0.03606,0.036226,17459.873],"400":[1598860800000,0.036226,0.03635,0.036148,0.036294,19987.223],"401":[1598864400000,0.036296,0.036478,0.036237,0.036359,13389.311],"402":[1598868000000,0.036359,0.036814,0.036339,0.03675,22840.375],"403":[1598871600000,0.036749,0.03715,0.036703,0.037021,31373.504],"404":[1598875200000,0.037021,0.03737,0.036916,0.037235,25816.35],"405":[1598878800000,0.037234,0.03731,0.036991,0.037053,28447.434],"406":[1598882400000,0.037056,0.03712,0.03686,0.03708,18423.258],"407":[1598886000000,0.03708,0.037097,0.03691,0.036976,17532.196],"408":[1598889600000,0.036975,0.037118,0.036931,0.036945,15637.591],"409":[1598893200000,0.036945,0.03707,0.03686,0.037069,12846.79],"410":[1598896800000,0.037069,0.037372,0.037059,0.037273,20462.839],"411":[1598900400000,0.037273,0.037396,0.03717,0.037256,18250.077],"412":[1598904000000,0.037255,0.037403,0.03681,0.03702,32733.91],"413":[1598907600000,0.03702,0.037162,0.03695,0.03704,13722.12],"414":[1598911200000,0.03704,0.037425,0.03698,0.037344,16798.579],"415":[1598914800000,0.037344,0.03749,0.03723,0.037235,20983.374],"416":[1598918400000,0.037237,0.037339,0.03708,0.037316,23647.815],"417":[1598922000000,0.037315,0.037525,0.037315,0.037523,13351.156],"418":[1598925600000,0.037523,0.037574,0.037451,0.037561,19345.209],"419":[1598929200000,0.037562,0.037991,0.037543,0.037949,31710.566],"420":[1598932800000,0.037948,0.038167,0.037859,0.03809,33119.748],"421":[1598936400000,0.03809,0.038625,0.03791,0.038621,44414.302],"422":[1598940000000,0.038625,0.039296,0.038605,0.03908,69390.478],"423":[1598943600000,0.03908,0.039173,0.038553,0.038866,39056.471],"424":[1598947200000,0.038866,0.03887,0.03855,0.038709,24445.435],"425":[1598950800000,0.038709,0.03954,0.03864,0.039392,42642.255],"426":[1598954400000,0.039392,0.03965,0.039126,0.03952,38857.23],"427":[1598958000000,0.039518,0.0396,0.03925,0.039479,33127.755],"428":[1598961600000,0.039481,0.039588,0.039373,0.039479,24254.663],"429":[1598965200000,0.03948,0.039629,0.039372,0.039491,20783.833],"430":[1598968800000,0.039493,0.039718,0.03903,0.039706,40754.556],"431":[1598972400000,0.039713,0.040555,0.039689,0.04003,76533.108],"432":[1598976000000,0.040027,0.040117,0.039591,0.039859,45048.551],"433":[1598979600000,0.039859,0.03992,0.03962,0.039722,28710.556],"434":[1598983200000,0.039718,0.039911,0.0397,0.03986,20170.925],"435":[1598986800000,0.039857,0.03998,0.0397,0.039784,21490.52],"436":[1598990400000,0.039778,0.040153,0.039778,0.040131,18766.522],"437":[1598994000000,0.040131,0.040311,0.04001,0.040173,21211.681],"438":[1598997600000,0.040173,0.040575,0.040125,0.040209,35153.361],"439":[1599001200000,0.040209,0.040393,0.03984,0.039875,29093.84],"440":[1599004800000,0.039875,0.04006,0.03928,0.039417,47899.949],"441":[1599008400000,0.039416,0.039775,0.03924,0.039641,33657.314],"442":[1599012000000,0.039636,0.0399,0.03947,0.039637,26661.631],"443":[1599015600000,0.039636,0.039894,0.039614,0.03971,21842.277],"444":[1599019200000,0.039709,0.04023,0.039709,0.04011,28564.547],"445":[1599022800000,0.040115,0.040444,0.04009,0.040158,26472.26],"446":[1599026400000,0.040156,0.0402,0.040032,0.040166,23519.197],"447":[1599030000000,0.040166,0.0402,0.03977,0.039833,19592.987],"448":[1599033600000,0.039831,0.0401,0.039671,0.040021,26076.458],"449":[1599037200000,0.040021,0.0402,0.03999,0.040125,16040.027],"450":[1599040800000,0.040123,0.04015,0.03962,0.039692,34429.528],"451":[1599044400000,0.039695,0.039709,0.03765,0.038742,81021.471],"452":[1599048000000,0.038741,0.03912,0.03851,0.03884,35280.759],"453":[1599051600000,0.038838,0.0392,0.038741,0.038953,28215.874],"454":[1599055200000,0.038953,0.038994,0.037989,0.03832,34111.674],"455":[1599058800000,0.038321,0.03865,0.03812,0.038179,23608.93],"456":[1599062400000,0.038177,0.038412,0.037459,0.037826,38176.639],"457":[1599066000000,0.037826,0.038248,0.037743,0.038021,23675.545],"458":[1599069600000,0.03802,0.038307,0.037837,0.038304,15427.109],"459":[1599073200000,0.038303,0.038397,0.038044,0.038259,20789.729],"460":[1599076800000,0.038256,0.03848,0.038057,0.03838,10117.326],"461":[1599080400000,0.038375,0.038535,0.038311,0.03852,7082.013],"462":[1599084000000,0.038518,0.03891,0.03834,0.038738,16178.534],"463":[1599087600000,0.03874,0.038805,0.0385,0.0386,11514.479],"464":[1599091200000,0.038596,0.039003,0.038512,0.038932,16397.296],"465":[1599094800000,0.038933,0.039253,0.038806,0.039251,15126.77],"466":[1599098400000,0.039251,0.039443,0.03912,0.039189,17290.812],"467":[1599102000000,0.039193,0.039254,0.038833,0.03901,16969.231],"468":[1599105600000,0.03901,0.039193,0.038444,0.038566,20830.118],"469":[1599109200000,0.038572,0.038652,0.038167,0.038301,24482.594],"470":[1599112800000,0.038302,0.038412,0.037867,0.037914,27597.582],"471":[1599116400000,0.037906,0.038351,0.037687,0.038321,24847.497],"472":[1599120000000,0.038325,0.038394,0.038181,0.038389,16531.963],"473":[1599123600000,0.038389,0.038443,0.03798,0.037986,12191.845],"474":[1599127200000,0.037986,0.0381,0.03759,0.03774,21776.838],"475":[1599130800000,0.037734,0.03801,0.037618,0.037716,25045.182],"476":[1599134400000,0.037716,0.038135,0.037025,0.038122,51990.407],"477":[1599138000000,0.038122,0.038357,0.037725,0.03833,26986.237],"478":[1599141600000,0.038331,0.038355,0.037758,0.038024,24130.72],"479":[1599145200000,0.03802,0.038147,0.037265,0.03783,39982.113],"480":[1599148800000,0.037816,0.038,0.037095,0.037119,47216.28],"481":[1599152400000,0.037105,0.037789,0.037082,0.03743,36002.074],"482":[1599156000000,0.037429,0.037584,0.037072,0.037398,27760.988],"483":[1599159600000,0.037396,0.0378,0.0373,0.037586,21728.782],"484":[1599163200000,0.037586,0.037983,0.037554,0.037673,19571.652],"485":[1599166800000,0.037672,0.037723,0.03729,0.037506,10263.674],"486":[1599170400000,0.037508,0.037566,0.03708,0.037148,16270.52],"487":[1599174000000,0.037148,0.037799,0.036483,0.037616,63415.317],"488":[1599177600000,0.037615,0.037833,0.03711,0.037733,41170.341],"489":[1599181200000,0.037734,0.03789,0.037626,0.037757,17914.87],"490":[1599184800000,0.037757,0.03783,0.037353,0.037683,21051.734],"491":[1599188400000,0.037682,0.037798,0.037272,0.037329,14159.89],"492":[1599192000000,0.037328,0.037672,0.0373,0.037645,17219.711],"493":[1599195600000,0.037639,0.037785,0.037537,0.03774,12097.12],"494":[1599199200000,0.03774,0.037773,0.037388,0.037416,15033.632],"495":[1599202800000,0.037416,0.03753,0.036952,0.037491,27779.282],"496":[1599206400000,0.037484,0.038144,0.037481,0.03797,26236.417],"497":[1599210000000,0.037965,0.0381,0.0378,0.03801,14076.31],"498":[1599213600000,0.038009,0.038035,0.03775,0.037757,15145.168],"499":[1599217200000,0.037752,0.03789,0.037629,0.037764,10195.703],"level":"debug","message":"Candles ETH/BTC"}

bennycode commented 4 years ago

I checked the RSI implementation of two other libraries (FinTA & Tulip Node aka tulind). For my investigation I used the 500 candles you provided on 2020-09-02T18:10:23Z and a RSI interval of 14.

In order to use your candles with FinTA, I converted them into a CSV format:

data.csv

date,open,high,low,close,volume
1597273200000,0.0000111,0.00001113,0.00001096,0.00001112,650403
1597276800000,0.00001111,0.00001114,0.00001097,0.00001101,457490
1597280400000,0.00001104,0.00001125,0.00001101,0.00001123,536601
1597284000000,0.00001123,0.00001123,0.00001089,0.00001093,542504
1597287600000,0.00001095,0.0000113,0.00001095,0.00001125,755025
1597291200000,0.00001125,0.00001125,0.00001114,0.00001118,86226
1597294800000,0.00001118,0.00001459,0.00001112,0.0000138,27663565
...

Here is the Python code which I used to run FinTA:

import pandas as pd
from finta import TA

dataFile = ("data.csv")
ohlc = pd.read_csv(dataFile, index_col="date", parse_dates=True)

dataSeries = TA.RSI(ohlc, 14, "close")
for result in dataSeries:
    print(result)

And here is what I coded in JavaScript to test tulind:

const tulind = require('tulind');

const dataFile = require('./src/data.json');
const ohlc = Object.values(dataFile);
const closes = ohlc.map(([time, open, high, low, close, volume]) => (close));

tulind.indicators.rsi.indicator([closes], [14], (error, [dataSeries]) => {
  for (const result of dataSeries) {
    console.log(result);
  }
});

What was interesting to notice is that tulind only returns 486 values because it skips the first 14 to fulfill the minimum requirement of the RSI interval.

When comparing the results of FinTA and tulind, I noticed that the RSI values are very different and converge only towards the end. After feeding 325 candles, both RSI calculations start to match up to 8 decimal places but before the results are very different. However, I don't know why the results are so different. Here are my measurements:

First 28 out of 500 / FinTA

nan
0.0
68.2926829268291
34.09690879672996
58.161826778726436
53.55490734416046
88.92243730536691
89.69644723091685
79.47963366905006
73.33611758591941
75.45249514269048
75.45249514269048
67.33093653434369
74.79035972344631
80.55707975395742
77.77326524216967
78.61589338165818
81.21494432039324
68.06954240289863
68.85374676681835
71.1977182765738
69.09768598412933
60.9643317318536
64.98069260135014
61.399972552139026
57.107328285281504
56.65829216132169
52.33723959135567

First 28 out of 500 / Tulind

-
-
-
-
-
-
-
-
-
-
-
-
-
-
78.99728997289972
77.08502847843774
77.70054208795223
79.69140029954299
69.7911986560964
70.36391417603085
72.11564504735239
70.43433839781844
63.71546764482072
66.80116729193077
63.729300664117616
59.96761822477232
59.569029891694115
55.68288649554418

Last 28 out of 500 / FinTA

23.106464149797574
30.590286624450457
41.60699085142529
37.998617907834
37.30184681660623
33.35037427109381
32.728098571047454
37.148393436984954
36.77662200248154
38.110654922051495
32.88054744579729
45.99335977503419
40.4439239721157
44.30371120554942
43.92053405951879
45.44493943410317
47.49433678617597
49.04052383182666
51.10789309217911
51.10789309217911
51.10789309217911
51.71948127549921
49.07508770770835
53.55090096390971
50.80314054366433
49.43723416004164
47.379465839257904
47.379465839257904

Last 28 out of 500 / Tulind

23.106464149797752
30.59028662445061
41.60699085142538
37.9986179078341
37.30184681660633
33.35037427109392
32.72809857104754
37.14839343698503
36.776622002481616
38.11065492205157
32.88054744579737
45.993359775034236
40.44392397211573
44.303711205549455
43.920534059518836
45.44493943410319
47.494336786176
49.04052383182668
51.10789309217913
51.10789309217913
51.10789309217913
51.71948127549925
49.075087707708384
53.55090096390973
50.80314054366435
49.43723416004166
47.37946583925793
47.379465839257925
bennycode commented 4 years ago

Here are the results from this library:

First 28 out of 500 / new RSI(14, SMMA)

-
-
-
-
-
-
-
-
-
-
-
-
-
-
78.99728997289902982499
77.08502847843735504649
77.70054208795221642085
79.69140029954239521135
69.79119865609655006476
70.36391417603037177606
72.11564504735093799586
70.4343383978173918296
63.71546764481898940039
66.80116729192911727708
63.72930066411581115113
59.96761822477091285642
59.56902989169239305168
55.68288649554270026928

Last 28 out of 500 / new RSI(14, SMMA)

23.10646414980839883004
30.5902866244602543963
41.6069908514297369995
37.99861790784142930002
37.3018468166083784932
33.35037427109941853942
32.72809857105177425905
37.1483934369898802326
36.77662200248327577075
38.11065492205407034887
32.8805474457965578265
45.99335977503659446557
40.44392397211760077912
44.30371120554844060176
43.92053405951703001097
45.44493943410062888127
47.49433678617084223477
49.04052383182118557122
51.1078930921750616213
51.10789309218001300056
51.10789309218477015815
51.71948127550987831267
49.07508770771804518572
53.55090096391995356815
50.80314054367156693383
49.43723416004588100032
47.3794658392604778574
47.37946583926157735424

First 28 out of 500 / new RSI(14, EMA)

-
-
-
-
-
-
-
-
-
-
-
-
-
-
79.94345778447897970225
76.22259764471053539072
77.50191268470815696162
81.41248013483144883486
62.82279550411432542989
64.18576297243049285386
68.31043636006362556056
65.06793576247938672883
52.89934018778524145924
60.59294124372111685817
55.12475097136752947655
48.70124808396298087458
48.02159673841139331582
41.50528292519171878675

Last 28 out of 500 / new RSI(14, EMA)

15.71376333207428554192
29.21518730887615310086
46.88587206796100101557
40.41797314054968556046
39.17098138740013061931
32.27685267394508169702
31.22016466150374636015
39.25181607217844886234
38.51055136605511488079
41.07838063065319478743
30.71748771238699995276
53.12776534063336666275
42.72753847223873312109
48.88518420086748723081
48.13869914224164022283
50.74237259092378233521
54.27413652181971067562
56.94557479229997232819
60.49622935390094741278
60.49622935390094741278
60.49622935390094741278
61.70897939462574940659
54.05053378900856173963
63.25801496795171306082
55.87569048589554005299
52.35100397447581281471
47.19800130660827224798
47.19800130660827224798

Looking at the results, using RSI with SMMA using my library (trading-signals) goes hand-in-hand with what tulind calculates. When switching to EMA the results become different (as expected). FinTA seems to be the one which is off in general. 🤷

bennycode commented 4 years ago

@Stevenje I added tests to verify the integrity with "tulind" (https://github.com/bennyn/trading-signals/pull/71) and released a new patch version of "trading-signals": https://www.npmjs.com/package/trading-signals/v/1.1.1

Cinemacloud commented 3 years ago

bennyn: terrific work on library however as this thread details/explores, I can't get the RSI to match TradingView on SPY still.. I'm using same 14 period closes and I've tried variations of EMA and SMMA and no parameters. In fact the price action doesn't even respond predictably to 70/30 its often more opposite of the trend. I'm testing 1 minute OHLC from 2020-09-08

bennycode commented 3 years ago

Hi @Cinemacloud, do you know what "black magic" is used in TradingView? I have checked my implementation and as proven it is compliant with the implementation from FinTA & Tulip Node.

Cinemacloud commented 3 years ago

Ha @bennyn, good question. I don't know but I've spent many hours now trying to get TV alignment to various libs including yours without success yet. Here is the 2020-09-08 1m dataset if you would try to do a similar test with results that match TV I'd be most grateful. Data: https://pastebin.com/cKXHd8N1

kingkong404 commented 3 years ago

Hey guys, one thing to note is depending on what candle type you have selected in trading view it will effect how the RSI is calculated. Make sure it's set to Candles in the view. That helped me. image

dilame commented 1 year ago

After some investigation, I have found that the RSI indicator provides the same result as TradingView when you provide interval * 7 klines. I assume TradingView does the same – just takes more historical data