Cant understand the problem...can anyone tell what is wrong with it?

http://drive.google.com/file/d/1qOIQQPt9Be86bnJnuLAzoU7WsLhdxV3Z/view?usp=sharing

def shape(data):
    
    if [data['Open'] < data['Close']]:
        if [data['Open'] > data['Low']]:
            if [data['High'] > data['Close']]:
                a = 1
                return a
            if [data['High'] == data['Open']]:
                b = 10
                return b
        if [data['Low'] == data['Open']]:
            if [data['Close'] > data['Open']]:
                c=3
                return c
            if [data['High'] == data['Close']]:
                d = 7
                return d
    
    if [data['Open'] > data['Close']]:
        if [data['Close'] == data['Low']]:
            if [data['High'] == data['Open']]:
                e = 4
                return e
            if [data['High'] > data['Open']]:
                f = 6
                return f
        if [data['Close'] > data['Low']]:
            if [data['High'] == data['Open']]:
                g= 11
                return g
            if [data['High'] > data['Open']]:
                h = 13
                return h
            
    if [data['Open'] == data['Close']]:
        if [data['Open'] == data['Low']]:
            if data['High'] > data['Close']:
                i = 5
                return i
        if [data['High'] == data['Close']]:
            if [data['Low'] < data['Open']]:
                j = 8
                return j 
        if [data['Close'] > data['Low']]:
            if [data['Open'] < data['High']]:
                k = 12
                return k
        
    if [data['Open'] == data['Close']]:
        if [data['High'] == data['Low']]:
            if [data['High'] > data['High'].shift(-1)]:
                l = 2
                return l
            if [data['Low'] < data['Low'].shift(-1)]:
                m = 9
                return m

dd['Shape'] = shape(dd)

Hi Abhishek,



Can you please specify what error you are getting? You can also share with us what you are trying to achieve so we can better understand the problem. You can also share your notebook here or if you don't want to share the notebook publically you can mail it at quantra@quantinsti.com



Thanks

The code is to get the shape of the candle using OHLC data. But after saving it as function and running it, we r only getting the first if condition but it's not going further…bcoz of that the whole shape column is 1

To recognize the candlestick pattern there are various functions in the Ta-lib library, you can check them on the Ta-lib GitHub page. You can also refer to this media article on how to recognize candlestick patterns. If you don't have Ta-lib installed on your system you can refer to this article How to install Ta-Lib in Python.