在Python中使用ta-lib时,有哪些数字,如-100,+ 100,-200,+ 200等?

时间:2016-04-24 06:54:12

标签: python ta-lib

我使用ta-lib进行烛台的模式识别,但是,我根据我使用过的模式函数得到了不同的数字。这些数字代表什么参考?

4 个答案:

答案 0 :(得分:1)

TA-Lib的库返回-100 .. + 100个值。包装器什么都没改变。 解释可能在不同的函数中有所不同,但一般来说:值== 0为假,值!= 0为真。标志可能代表方向 对于CDLHANGINGMAN,其C代码为here

根据描述:

   /* Proceed with the calculation for the requested range.
* Must have:
* - small real body
* - long lower shadow
* - no, or very short, upper shadow
* - body above or near the highs of the previous candle
* The meaning of "short", "long" and "near the highs" is specified with TA_SetCandleSettings;
* outInteger is negative (-1 to -100): hanging man is always bearish;
* the user should consider that a hanging man must appear in an uptrend, while this function does not consider it
*/

虽然我觉得它很不正确,因为CDLHANGINGMAN只返回-100或0。

        if( TA_REALBODY(i) < TA_CANDLEAVERAGE( BodyShort, BodyPeriodTotal, i ) &&                        // small rb
        TA_LOWERSHADOW(i) > TA_CANDLEAVERAGE( ShadowLong, ShadowLongPeriodTotal, i ) &&              // long lower shadow
        TA_UPPERSHADOW(i) < TA_CANDLEAVERAGE( ShadowVeryShort, ShadowVeryShortPeriodTotal, i ) &&    // very short upper shadow
        min( inClose[i], inOpen[i] ) >= inHigh[i-1] - TA_CANDLEAVERAGE( Near, NearPeriodTotal, i-1 ) // rb near the prior candle's highs
      )
        outInteger[outIdx++] = -100;
    else
        outInteger[outIdx++] = 0;

根本无法从此功能获得+100。

我还没有看到任何完整的参考资料。最好先了解一下TA-func代码。蜡烛功能&#39;代码很简单。

答案 1 :(得分:1)

-200 / -100 / 0 / +100 / +200

+200 带有确认的看涨形态
+100 看涨形态(大多数情况)
0
-100 看跌形态
-200 带有确认的看跌形态

例如
如果有CDLHIKKAKE模式检测功能:
正如您在源代码中看到的那样:

https://sourceforge.net/p/ta-lib/code/HEAD/tree/trunk/ta-lib/c/src/ta_func/ta_CDLHIKKAKE.c#l240

您可以再获得-100或+100(即为-200 / + 200):
如果您的模式已经确认
因此计算将为(模式+确认)
这样,
您可能会在某些天检测到看跌模式,再过一天可以确认该模式。最后得到-200

答案 2 :(得分:0)

根据discussion

  

-100表示​​看跌的三星图案,其中中间的蜡烛体高于另外两个。相反,+ 100表示​​看涨的三星模式,其中中间体位于相邻的下方。

该页面显示了一些示例和相关的源代码。

/* Proceed with the calculation for the requested range.
* Must have:
* - 3 consecutive doji days
* - the second doji is a star
* The meaning of "doji" is specified with TA_SetCandleSettings
* outInteger is positive (1 to 100) when bullish or negative (-1 to -100) when bearish
*/
i = startIdx;
outIdx = 0;
do
{
     if( TA_REALBODY(i-2) <= TA_CANDLEAVERAGE( BodyDoji, BodyPeriodTotal, i-2 ) &&    // 1st: doji
         TA_REALBODY(i-1) <= TA_CANDLEAVERAGE( BodyDoji, BodyPeriodTotal, i-2 ) &&    // 2nd: doji
         TA_REALBODY(i) <= TA_CANDLEAVERAGE( BodyDoji, BodyPeriodTotal, i-2 ) ) {     // 3rd: doji
         outInteger[outIdx] = 0;
         if ( TA_REALBODYGAPUP(i-1,i-2)                                                  // 2nd gaps up
              &&
              max(inOpen[i],inClose[i]) < max(inOpen[i-1],inClose[i-1])                  // 3rd is not higher than 2nd
            )
             outInteger[outIdx] = -100;
         if ( TA_REALBODYGAPDOWN(i-1,i-2)                                                // 2nd gaps down
              &&
              min(inOpen[i],inClose[i]) > min(inOpen[i-1],inClose[i-1])                  // 3rd is not lower than 2nd
            )
             outInteger[outIdx] = +100;
         outIdx++;
     }
     else
         outInteger[outIdx++] = 0;
     /* add the current range and subtract the first range: this is done after the pattern recognition 
     * when avgPeriod is not 0, that means "compare with the previous candles" (it excludes the current candle)
     */
     BodyPeriodTotal += TA_CANDLERANGE( BodyDoji, i-2 ) - TA_CANDLERANGE( BodyDoji, BodyTrailingIdx );
     i++;
     BodyTrailingIdx++;
} while( i <= endIdx );

答案 3 :(得分:-1)

请参阅此视频。他解释了-100和100。甚至引用了此页面。

https://youtu.be/lrYu9AnPw7Q?t=120

https://github.com/mrjbq7/ta-lib/issues/74

** -100表示​​看跌的Tristar模式,其中中间的蜡烛体位于其他两个蜡烛体上方。相反,+ 100表示​​看涨的Tristar模式,其中中体位于相邻的下方。

What are the numbers such as -100, +100, -200, +200 and etc, when using ta-lib in Python? **