deraera909
deraera909 27 Dec 2022, 12:51 ( Updated at: 27 Dec 2022, 15:53 )
Hey,
Thanks for the help so far. I've updated the code and it's still not placing any trades. Am I looking at this wrong or should this be working?
foreach (var order in PendingOrders) { //int totalBuyPositions = Positions.Count(item => item.OrderType == PendingOrderType.Limit && item.TradeType == TradeType.Buy); var buyPositions = Positions.Find("myBuyOrder", "AUDUSD"); var sellPositions = Positions.Find("mySellOrder", "AUDUSD"); int totalBuyOrders = PendingOrders.Count(item => item.OrderType == PendingOrderType.Limit && item.TradeType == TradeType.Buy); int totalSellOrders = PendingOrders.Count(item => item.OrderType == PendingOrderType.Limit && item.TradeType == TradeType.Sell); // 2 orders if ((totalBuyOrders == 1) && (totalSellOrders == 1)) { Print("Testing Testing, 1, 2, 3, Testing."); } // 1 order if (totalBuyOrders == 1 || totalSellOrders == 1) { CancelPendingOrder(order); } // 0 orders //if ((PendingOrders.Count(item => item.OrderType == PendingOrderType.Limit && item.TradeType == TradeType.Buy) == 0) && (PendingOrders.Count(item => item.OrderType == PendingOrderType.Limit && item.TradeType == TradeType.Sell) == 0)) if ((totalBuyOrders == 0) && (totalSellOrders == 0)) { //var checkBuyPosition = Positions.Find("myBuyOrder", SymbolName, TradeType.Buy); //var checkSellPosition = Positions.Find("mySellOrder", SymbolName, TradeType.Sell); // 0 Positions if ((buyPositions == null) && (sellPositions == null)) { PlaceLimitOrder(TradeType.Buy, SymbolName, 1, Symbol.Ask-2*Symbol.PipSize, "myBuyOrder"); PlaceLimitOrder(TradeType.Sell, SymbolName, 1, Symbol.Bid-2*Symbol.PipSize, "mySellOrder"); var buyPosition = Positions.Find("myBuyOrder", SymbolName, TradeType.Buy); var sellPosition = Positions.Find("mySellOrder", SymbolName, TradeType.Sell); if (buyPosition != null) { ModifyPosition(buyPosition, buyLoss, buyProfit); } if (sellPosition != null) { ModifyPosition(sellPosition, sellLoss, sellProfit); } } } }
deraera909
27 Dec 2022, 12:51 ( Updated at: 27 Dec 2022, 15:53 )
Hey,
Thanks for the help so far. I've updated the code and it's still not placing any trades. Am I looking at this wrong or should this be working?
@deraera909