php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62698 trader_t3 does not return results
Submitted: 2012-07-30 16:09 UTC Modified: 2012-07-30 19:28 UTC
From: mike at saymikeo dot com Assigned:
Status: Not a bug Package: Trader (PECL)
PHP Version: 5.3.15 OS: OSX
Private report: No CVE-ID: None
 [2012-07-30 16:09 UTC] mike at saymikeo dot com
Description:
------------
input vars
array of numbers and time period

returns an empty array.

Thanks!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-30 17:03 UTC] ab@php.net
Are you using trunk? This pattern works for me

var_dump(trader_t3(get_data("high", $data1)));

with the data and function from
tests/inc/data.php
tests/inc/func.php

As well when i pass a time period.

Please give more info on how you run it, how much data, which time period.
 [2012-07-30 17:15 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2012-07-30 18:10 UTC] mike at saymikeo dot com
Yes I am using the trunk. Here is a sample of the data I am passing.

$settings['period'] = 20;

$data = trader_t3($close, $settings['period']);

// This is set before the function but placed below for readability 
$close = Array ( [0] => 568.1 [1] => 589.58 [2] => 585.56 [3] => 585.57 [4] => 
601.1 [5] => 605.96 [6] => 602.5 [7] => 599.34 [8] => 596.05 [9] => 606.98 [10] 
=> 614.48 [11] => 617.62 [12] => 609.86 [13] => 599.55 [14] => 618.63 [15] => 
629.32 [16] => 624.31 [17] => 633.68 [18] => 636.23 [19] => 628.44 [20] => 626.2 
[21] => 622.77 [22] => 605.23 [23] => 580.13 [24] => 609.7 [25] => 608.34 [26] => 
587.44 [27] => 572.98 [28] => 571.7 [29] => 560.28 [30] => 610 [31] => 607.7 [32] 
=> 603 [33] => 583.98 [34] => 582.13 [35] => 585.98 [36] => 581.82 [37] => 565.25 
[38] => 569.48 [39] => 568.18 [40] => 569.18 [41] => 570.52 [42] => 566.71 [43] 
=> 558.22 [44] => 553.17 [45] => 546.08 [46] => 530.12 [47] => 530.38 [48] => 
561.28 [49] => 556.97 [50] => 570.56 [51] => 565.32 [52] => 562.29 [53] => 572.27 
[54] => 579.17 [55] => 577.73 [56] => 560.99 [57] => 564.29 [58] => 562.83 [59] 
=> 571.46 [60] => 571.72 [61] => 580.32 [62] => 571.17 [63] => 576.16 [64] => 
572.16 [65] => 571.53 [66] => 574.13 [67] => 585.78 [68] => 587.41 [69] => 585.74 
[70] => 577.67 [71] => 582.1 [72] => 570.77 [73] => 572.03 [74] => 574.5 [75] => 
569.05 [76] => 584 )
 [2012-07-30 19:22 UTC] ab@php.net
Looks like what you expierience is due to the too high time period. T3 is one of 
the indexes sensitive to the so called "unstable period". Please take a look at 
this page http://www.ta-lib.org/d_api/ta_setunstableperiod.html . Also looking 
at 
the TA-Lib itself here http://lxr.php.net/xref/PECL/trader/ta-
lib/src/ta_func/ta_T3.c#241 the needed lookback is calculated as 6 * 
(optInTimePeriod - 1), in case of time period being 20 it were 114 which is way 
too high above count($close).

Valid possibilities i see here is to give more data or decrease the time period.  

Another way would be to set the unstable period factor to a negative enough 
number (trunk only now), but that would be identical to decreasing the time 
period.
 [2012-07-30 19:28 UTC] ab@php.net
This is completely undocumented now, you can use 

trader_set_unstable_period(int functionId, int timePeriod)

Use TRADER_FUNC_UNST_T3 as function id or look here for possible others ids

http://lxr.php.net/xref/PECL/trader/trader.c#1296
 [2012-07-30 19:28 UTC] ab@php.net
-Status: Feedback +Status: Not a bug
 [2012-07-30 19:41 UTC] mike at saymikeo dot com
Superb. Thank you for providing such a great explanation. I pulled in more data 
and everything works well.

thanks,
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 10:01:26 2019 UTC