michaelB wrote >>
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
michaelB:
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
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.