Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect use of MACD / SMA / EMA ... in Indicators? #114

Open
sixcom opened this issue May 5, 2018 · 3 comments
Open

Incorrect use of MACD / SMA / EMA ... in Indicators? #114

sixcom opened this issue May 5, 2018 · 3 comments

Comments

@sixcom
Copy link

sixcom commented May 5, 2018

I am curious about the usage of results of something like trader_macd() / trader_sma() ?

  1. $this->getRecentData() gets the data in descending order e.g.
    <?php return [ '2018-01-03' => 5, '2018-01-02' => 15, '2018-01-01' => 20, ];

  2. trader_sma($recnetData, 2) will get
    <?php return [ 10, 20]

  3. In the code, pretty much everywhere uses array_pop() which returns the last element of array (in this case 20 is returned, but actually 10 is the latest SMA)

Is this correct? The default data size is 168, if the interval is one day then SMA result is average of some price data 100+ days ago, should it use the first element from the result array?

@nasyrov
Copy link

nasyrov commented Jun 22, 2018

@sixcom just use array_reverse before you pass your data to indicators

@joeldg
Copy link
Owner

joeldg commented Jun 22, 2018

@nasyrov
Copy link

nasyrov commented Jun 22, 2018

@joeldg fair enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants