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
Post a Comment