Skip to content

bbands reporting "Undefined array key 22"  #18

@pottertech

Description

@pottertech

Message: Uncaught ErrorException: Undefined array key 22 in /root/vendor/lupecode/php-trader-native/source/TALib/Core/OverlapStudies.php:1657

It happens when I call LupeCode\phpTraderNative\Trader::bbands()

I added some debug statements into the t3() that gets called.

UnstablePeriodFunctionID::T3 value is 22

I then var_dump(static::$unstablePeriod) and the array size is 21 as seen below:

array(21) {
[0]=>
int(0)
[1]=>
int(0)
[2]=>
int(0)
[3]=>
int(0)
[4]=>
int(0)
[5]=>
int(0)
[6]=>
int(0)
[7]=>
int(0)
[8]=>
int(0)
[9]=>
int(0)
[10]=>
int(0)
[11]=>
int(0)
[12]=>
int(0)
[13]=>
int(0)
[14]=>
int(0)
[15]=>
int(0)
[16]=>
int(0)
[17]=>
int(0)
[18]=>
int(0)
[19]=>
int(0)
[20]=>
int(0)
}

When I edit the Core.php file and change
static::$unstablePeriod = \array_pad([], UnstablePeriodFunctionID::ALL - 2, 0);
to
static::$unstablePeriod = \array_pad([], UnstablePeriodFunctionID::ALL, 0);

The error goes away. I am not sure if this is a good fix or not, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions