Skip to content

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

@robertgdev

Description

@robertgdev

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions