self.order = self.buy(exectype=bt.Order.Market, tradeid=self.TradeID)
self.TP_order = self.sell(tradeid = self.TradeID, exectype=bt.Order.Limit,price=self.takeprofit,oco=self.order)
self.SL_order = self.sell(tradeid = self.TradeID, exectype=bt.Order.Stop, price=self.stoploss,oco=self.order)
I don't know what your goal is there but those two cannot be
OCO of another order, because they will be cancelled when the first order is executed. Hence no hits, because they no longer exist as soon as the other is executed. The manual stop-loss/take-profit can only be set once your market order is executed, and one of them has to be
oco of the other.
My recommendation is that you take MANY steps back, stop thinking about your Deep Learning Space 9 super-duper model and concentrate on the basics of being able to send orders to the market as wished.
Create a simple script which sends order to the market using a moving average cross over. Once you understand how orders work you can add as many Artificial Intelligence as you wish. But knowing how trading works is a pre-requisite you cannot forego.