MQL5 : Get running pnl

 mtm=AccountInfoDouble(ACCOUNT_PROFIT);



 Get running pnl  by magin number for specific chart

double GetPnLByMagicNumber(int magic_number)

  {

   double total_pnl = 0.0;

   for(int i = 0; i < PositionsTotal(); i++)

     {

      ulong ticket = PositionGetTicket(i);

      int position_magic = (int)PositionGetInteger(POSITION_MAGIC);

      if(position_magic == magic_number)

        {

         total_pnl += PositionGetDouble(POSITION_PROFIT);

        }


     }


   return total_pnl;

  }

Comments

Popular posts from this blog

MQL5 : Add time to current time in mins

MQL5: Closed order detail