AccountProfit by magic number.
AccountProfit() returns total profit value of the current account.
Is there a way to get profit value for only those orders created with a specific magic number ??
Thank you.
Hi Michael,
There is no command to do that. So what you have to do is loop through all of the opened orders and add up the profit based on OrderOpenPrice() and Bid or Ask, depending on what type of order it is, counting only the orders with the correct Magic Number that is.
- Tovan
AccountProfit() returns total profit value of the current account.
Is there a way to get profit value for only those orders created with a specific magic number ??
Thank you.
Yes.
double ProfitCount(int Magic) { int total=OrdersTotal()-1; double profsumm=0; for (int cnt = total ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic) { profsumm+=OrderProfit(); } } return(profsumm); }Cheers
AccountProfit() returns total profit value of the current account.
Is there a way to get profit value for only those orders created with a specific magic number ??
Thank you.