Last trade profit/loss? - page 2 12 New comment Ah-Ong 2021.10.13 05:20 #11 string Last; for(int i = OrdersHistoryTotal() - 1; i >= 0; i--) { if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue; if(OrderSymbol() != Symbol()) continue; if(OrderProfit() == 0) continue; // Skip pending order. The profit of Cancelled pending order is zero. if(OrderProfit() > 0) Last = "Profit"; if(OrderProfit() < 0) Last = "Loss"; break; } Print("Last Order is ",Last,", Symbol: ",OrderSymbol()," Profit / Loss: ",OrderProfit()); 12 New comment
string Last; for(int i = OrdersHistoryTotal() - 1; i >= 0; i--) { if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue; if(OrderSymbol() != Symbol()) continue; if(OrderProfit() == 0) continue; // Skip pending order. The profit of Cancelled pending order is zero. if(OrderProfit() > 0) Last = "Profit"; if(OrderProfit() < 0) Last = "Loss"; break; } Print("Last Order is ",Last,", Symbol: ",OrderSymbol()," Profit / Loss: ",OrderProfit());