can anyone guide me how to total up ? why the function of "TotalProfit"
in MQL II no longer be used in MQL4?
- Questions about MQL4
- Total profit in Pip
- Total Profit of all currently opened orders
Here's TotalProfit() back:
Hope it helps!
double TotalProfit() { int total = OrdersTotal(); double MyCurrentProfit=0; for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); MyCurrentProfit += OrderProfit(); } Return(MyCurrentProfit); }
Hope it helps!
Thanks, Codersguru.
I tried and managed to total up all open trades P/L.
Further if we want to total the profit/loss of only 2 or 3 specific open trades out of 6 open trades (for example)
either the open trades are same /different pair of currency, how do we code it?
Your reply is appreciated. TQ.
I tried and managed to total up all open trades P/L.
Further if we want to total the profit/loss of only 2 or 3 specific open trades out of 6 open trades (for example)
either the open trades are same /different pair of currency, how do we code it?
Your reply is appreciated. TQ.
double TotalProfit(string symbol) { int total = OrdersTotal(); double MyCurrentProfit=0; for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (symbol != OrderSymbol()) continue; MyCurrentProfit += OrderProfit(); } return(MyCurrentProfit); }
So, you should call "TotalProfit" function for each symbol your EA can trade.
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