python - Ta-lib evaluation order for building series -


i'm building indicator series based on market prices using ta-lib. made couple of implementations of same concept found same issue in implementation. obtain correct series of values must revert input series , revert resulting series. python code call ta-lib library through convenient wrapper is:

rsi1 = np.asarray(run_example(  function_name,                                  arguments,                                  30,                                  weeklynoflatopen[0],                                 weeklynoflathigh[0],                                 weeklynoflatlow[0],                                 weeklynoflatclose[0],                                 weeklynoflatvolume[0][::-1]))  rsi2 = np.asarray(run_example(  function_name,                                  arguments,                                  30,                                  weeklynoflatopen[0][::-1],                                 weeklynoflathigh[0][::-1],                                 weeklynoflatlow[0][::-1],                                 weeklynoflatclose[0][::-1],                                 weeklynoflatvolume[0][::-1]))[::-1] 

the graphs of both series can observed here (the indicator sma): enter image description here

the green line computed in reverse order (from n sample 0) , red 1 in expected order. achieve red line must reverse input series , output series.

the code of test available on: python code

anybody observed same behavior?

i found what's wrong approach problem. simple answer ma indicator puts first valid value on results array in position zero, result series starts 0 , has n less samples input series (where n period value in case). reverted computation idea wrong.

here's proof:

enter image description here

adding 30 zeros @ beginning , removing last ones indicator fits on input series nicely.

enter image description here


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -