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
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
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?