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):
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:
adding 30 zeros @ beginning , removing last ones indicator fits on input series nicely.
Comments
Post a Comment