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

Returned result does not match length of MA for trader_dema and trader_tema #6

Open
rgasch opened this issue Mar 31, 2024 · 0 comments

Comments

@rgasch
Copy link

rgasch commented Mar 31, 2024

I should preface this by saying that I'm not 100% sure that my understanding of these functions is correct and that I don't know that if this is a real issue, whether it's an issue of this extension or of the underlying ta-lib.

Consider the following test code for dema

<?php


$data   = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
$result = trader_dema($data, 3);
var_dump("LEN = 3", $result);
$result = trader_dema($data, 4);
var_dump("LEN = 4", $result);
$result = trader_dema($data, 5);
var_dump("LEN = 5", $result);

This results in the following output:

string(7) "LEN = 3"
array(6) {
  [4]=>
  float(50)
  [5]=>
  float(60)
  [6]=>
  float(70)
  [7]=>
  float(80)
  [8]=>
  float(90)
  [9]=>
  float(100)
}
string(7) "LEN = 4"
array(4) {
  [6]=>
  float(70)
  [7]=>
  float(80)
  [8]=>
  float(90)
  [9]=>
  float(100)
}
string(7) "LEN = 5"
array(2) {
  [8]=>
  float(90)
  [9]=>
  float(100)
}

There is a similar issue with the tema MA, but I'm not going to bore you with this until we establish that this is indeed a problem. Since this is a moving average indicator, I would expect the result to have N-L (where N is the number of input items and L is the length/period of the MA) items. However this is clearly not the case. Can you please comment on this?

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

1 participant