Hello Community,
I'm new to QuantConnect and still figuring out the Doc etc.
I hope someone can help me with this:
There should be a Market Order and simultaniously a Take Profit 40 pips above and a Stop Loss 100 pips below. It seems to work, but the orders never get filled. I do not see any profitable trades in the backtest pane and the log of the Filled and Canceled order is also never triggered.
# Trade execution
if (momentum >= 1.5) and (closePct >= 0.9):
marketOrder = self.MarketOrder(self.forex.Symbol, 1000)
self.Log('Market Order filled at: {}, Momentum: {}, ClosePct:, {}'.format(marketOrder.AverageFillPrice, momentum, closePct))
self.LimitOrder(self.forex.Symbol, -1000, t0bidClose+0.004)
self.StopMarketOrder(self.forex.Symbol, -1000, t0bidClose-0.01)
self.Log('TP: {}, SL: {}'.format((t0bidClose+0.004), (t0bidClose-0.01)))
def OnOrderEvent(self, orderEvent):
order = self.Transactions.GetOrderById(orderEvent.OrderId)
if order.Status == OrderStatus.Filled:
self.Log(str(orderEvent))
if order.Type == OrderType.Limit or order.Type == OrderTpye.StopMarket:
self.Transactions.CancelOpenOrders(order.Symbol)
if order.Status == OrderStatus.Canceled:
self.Log(str(orderEvent))
Thank you and I'm happy for any help.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!