Open prRZ5F4LXZ opened 3 years ago
As I can see from the C code the function is capable to return only values of -100, -80, 0, 80 or 100. While the commentary says:
* Must have:
* - first: black (white) real body
* - second: white (black) real body that engulfs the prior real body
* outInteger is positive (1 to 100) when bullish or negative (-1 to -100) when bearish:
* - 100 is returned when the second candle's real body begins before and ends after the first candle's real body
* - 80 is returned when the two real bodies match on one end (Greg Morris contemplate this case in his book
* "Candlestick charting explained")
* The user should consider that an engulfing must appear in a downtrend if bullish or in an uptrend if bearish,
* while this function does not consider it
The pattern tests are very simple in the source I have installed:
if( ( TA_CANDLECOLOR(i) == 1 && TA_CANDLECOLOR(i-1) == -1 && // white engulfs black
inClose[i] > inOpen[i-1] && inOpen[i] < inClose[i-1]
)
||
( TA_CANDLECOLOR(i) == -1 && TA_CANDLECOLOR(i-1) == 1 && // black engulfs white
inOpen[i] > inClose[i-1] && inClose[i] < inOpen[i-1]
)
)
outInteger[outIdx++] = TA_CANDLECOLOR(i) * 100;
else
outInteger[outIdx++] = 0;
The indicator can be seen working here:
from plotly.offline import plot
import plotly.graph_objs as go
import pandas as pd
import talib as ta
import re
import numpy as np
o = np.array([175.47, 171.61, 175.69, 181.74, 170.92, 187.07, 174.15, 175.47, 171.61, 175.69, 181.74, 170.92])
h = np.array([ 184.68, 184.39, 179.22, 183.49, 182.87,190.78, 196.48, 184.68, 184.39, 179.22, 183.49, 182.87])
l = np.array([169.16, 169.78, 166.80, 171.63, 170.10, 176.94, 170.13, 169.16, 169.78, 166.80, 171.63, 170.10])
c = np.array([169.30, 182.14, 176.60, 177.66, 170.70, 177.32, 192.34, 169.30, 182.14, 176.60, 177.66, 170.70])
print('CDLENGULFING ', ta.CDLENGULFING(o, h, l, c))
trace = go.Candlestick( #x= pd.to_datetime(dfohlc.index.values),
open=o,
high=h,
low=l,
close=c)
data = [trace]
plot(data, filename='go_candle1.html')
CDLENGULFING [ 0 0 0 0 0 0 100 0 0 0 0 0]
@trufanov-nok Where can you find the C documentation? all of these functions return an integer and I can't seem to find documentation on what the integers indicate
there is a mirror of the ta-lib C code here, you can see all the functions:
https://github.com/TA-Lib/ta-lib/blob/master/src/ta_func/ta_CDLENGULFING.c#L212
@runxc1 if you mean functions return value then it's a value defined in this enum: https://github.com/TA-Lib/ta-lib/blob/master/include/ta_defs.h#L234
0 -TA_SUCCESS, 2 - TA_BAD_PARAM, etc.
If you mean values returned in output array - they are indicator dependent.
Afaik, there is no much C documentation, so you better rely on commentaries in the code.
I am trying to test CDLENGULFING. Can anybody provide a data set so that CDLENGULFING can return 1?
I have the following code, but I only see CDLENGULFING returning 0.