ta-lib-python icon indicating copy to clipboard operation
ta-lib-python copied to clipboard

MACDEXT with MA type MAMA returns all zeros

Open bigtan opened this issue 10 years ago • 3 comments

import numpy as np
import talib as ta
close = np.random.random(10000)
ma_type=7
tmp = ta.MACDEXT(close, fastperiod=13, fastmatype=ma_type, slowperiod=21, slowmatype=ma_type, signalperiod=8,
                 signalmatype=ma_type)
print tmp

tmp is all nan and zeros here, i think maybe it is a bug

bigtan avatar Dec 17 '15 06:12 bigtan

Hmm, thats weird.

Unless it's a bug with initialization like #90 (which should be fixed), I'm not sure if its a bug with the C library or my Python wrapper. I'll try and look into it later.

Thanks for the report!

mrjbq7 avatar Dec 17 '15 17:12 mrjbq7

I'm also getting zeroes for the last 26 values of returns in my backtest when using the BBands and matype=7 MAMA.

                   last        upper        lower

date 2019-06-07 20:00:00 7896.3 8154.716927 7853.316571 2019-06-07 21:00:00 7951.6 8152.079877 7853.218212 2019-06-07 22:00:00 8024.6 8152.066720 7857.546743 2019-06-07 23:00:00 8000.5 8148.898065 7861.754619 2019-06-08 00:00:00 8051.0 8148.870565 7867.971952 2019-06-08 01:00:00 7975.4 8142.613068 7868.034119 2019-06-08 02:00:00 7987.5 8135.354177 7873.676238 2019-06-08 03:00:00 7955.1 8121.617390 7880.896812 2019-06-08 04:00:00 7992.1 8115.364557 7897.494498 2019-06-08 05:00:00 7963.9 8106.623630 7901.593239 2019-06-08 06:00:00 7920.4 8098.445625 7901.778126 2019-06-08 07:00:00 7941.4 8072.263005 7886.695601 2019-06-08 08:00:00 7983.4 8070.929429 7889.457772 2019-06-08 09:00:00 8004.1 8069.790594 7893.721459 2019-06-08 10:00:00 7990.0 8084.208339 7905.652035 2019-06-08 11:00:00 8008.9 8101.095011 7920.915456 2019-06-08 12:00:00 7952.5 8099.974595 7918.288461 2019-06-08 13:00:00 7972.0 8092.508561 7907.463388 2019-06-08 14:00:00 7935.1 8100.578844 7898.218078 2019-06-08 15:00:00 7942.4 8109.397355 7889.275538 2019-06-08 16:00:00 7851.4 8110.850130 7877.813333 2019-06-08 17:00:00 7849.9 8053.608878 7815.034125 2019-06-08 18:00:00 7840.0 8054.262821 7808.726160 2019-06-08 19:00:00 7832.1 8059.080409 7799.277700 2019-06-08 20:00:00 7876.5 0.000000 0.000000 2019-06-08 21:00:00 7888.3 0.000000 0.000000 2019-06-08 22:00:00 7939.2 0.000000 0.000000 2019-06-08 23:00:00 7928.7 0.000000 0.000000 2019-06-09 00:00:00 7895.5 0.000000 0.000000 2019-06-09 01:00:00 7890.0 0.000000 0.000000 2019-06-09 02:00:00 7873.2 0.000000 0.000000 2019-06-09 03:00:00 7895.0 0.000000 0.000000 2019-06-09 04:00:00 7898.2 0.000000 0.000000 2019-06-09 05:00:00 7902.3 0.000000 0.000000 2019-06-09 06:00:00 7889.1 0.000000 0.000000 2019-06-09 07:00:00 7922.8 0.000000 0.000000 2019-06-09 08:00:00 7924.5 0.000000 0.000000 2019-06-09 09:00:00 7898.4 0.000000 0.000000 2019-06-09 10:00:00 7893.1 0.000000 0.000000 2019-06-09 11:00:00 7875.6 0.000000 0.000000 2019-06-09 12:00:00 7767.5 0.000000 0.000000 2019-06-09 13:00:00 7759.2 0.000000 0.000000 2019-06-09 14:00:00 7787.0 0.000000 0.000000 2019-06-09 15:00:00 7749.6 0.000000 0.000000 2019-06-09 16:00:00 7649.0 0.000000 0.000000 2019-06-09 17:00:00 7658.0 0.000000 0.000000 2019-06-09 18:00:00 7683.1 0.000000 0.000000 2019-06-09 19:00:00 7744.6 0.000000 0.000000 2019-06-09 20:00:00 7726.0 0.000000 0.000000 2019-06-09 21:00:00 7639.0 0.000000 0.000000

usgoose avatar Jun 10 '19 17:06 usgoose

I'm also getting zeroes for the last 26 values of returns in my backtest when using the BBands and matype=7 MAMA.

I'm experiencing the same behavior for the upper and lower bands. This does not occur with other MA types.

Additionally, when I attempt to build my own bands with talib.MAMA and talib.STDDEV, I can't get them to be identical with the output from talib.BBANDS(matype=7). However, I can build identical bands to talib.BBANDS(matype=0) with talib.SMA and talib.STDDEV.

This is very strange. I can assert that talib.MAMA = the middle band from talib.BBands(matype=7). So the error may be with the upper and lower band calculations.

remingm avatar Oct 21 '20 00:10 remingm