Hi all,

A happy new year. A new year with struggles with .the algorithms.

When I open a trade, I immediately set a stop-loss and limit order. I work with a hourly resolution for multiple equities. It is possible that I open two (or more) trades at the same time, but then the code doesn't place limits for both trades.

So next part works for when I open one trade, but does nothing when I make two trades. I think it has something to do with the entry_ticket or with the OrderId. 

How can I set limit/stoploss for open trades or for multiple trades when I open them at the same time?

     ... Buy:
     self.entry_ticket = self.LimitOrder(self.Symbol, quantity, price))
        self.entry_ticket_time = self.Time.hour

    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status != OrderStatus.Filled:

            return

        if self.entry_ticket is not None:
            if orderEvent.OrderId == self.entry_ticket.OrderId:
                price = orderEvent.FillPrice
                quantity = orderEvent.Quantity
                self.LimitOrder(orderEvent.Symbol, -quantity, priceL)
                self.StopMarketOrder(orderEvent.Symbol, -quantity, priceS)
            else:
                self.entry_ticket = None