get Order profit by comment

6 April 2018, 11:30
Jatin Patel
0
19
double getProfitOfOrderPair(string pair)
{
    double pProfit = 0.0;
    for (int i = OrdersTotal() - 1; i >= 0; i--) // returns the number of open positions
    {
          if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {  
                        if(OrderComment() == pair) {
                                pProfit = pProfit + OrderProfit() + OrderSwap() + OrderCommission();
                        }
                }
        }
    return pProfit;
}


Share it with friends: