bowhead icon indicating copy to clipboard operation
bowhead copied to clipboard

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

Open sixcom opened this issue 7 years ago • 3 comments

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?

sixcom avatar May 05 '18 03:05 sixcom

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

nasyrov avatar Jun 22 '18 15:06 nasyrov

see: https://github.com/joeldg/bowhead/blob/master/app/Traits/OHLC.php#L33

joeldg avatar Jun 22 '18 16:06 joeldg

@joeldg fair enough

nasyrov avatar Jun 22 '18 16:06 nasyrov