Profit counting
ggekko:
Please, help me to resolve this problem: I'd like to count the total amount of profit that belongs to a magic number (there are other orders with different magic on the account).
Here is my code:
It shows just the profit of the last order, not the total. What is the good solution?You have some mistakes, try the changes bellow.
figurelli@fxcoder.com
double MagicProfit(int Magic) { double profit=0; int total=OrdersTotal()-1; for (int cnt = total ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic) { profit+=OrderProfit(); } } return(profit); } // Call example P1 = MagicProfit(25); // return profit of Magic = 25
figurelli:
You have some mistakes, try the changes bellow.
Rogerio Figurelli
figurelli@fxcoder.com
www.fxcoder.com
Thank you!
https://www.mql5.com/en/code/8640
hth
Russell
Please, help me to resolve this problem: I'd like to count the total amount of profit that belongs to a magic number (there are other orders with different magic on the account).
Here is my code:
It shows just the profit of the last order, not the total. What is the good solution?