#include <stdlib.mqh> int OnInit(){ EventSetTimer(3); } void OnTimer(){ Symbol() =="EURJPY+"; OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES); double A = OrderProfit(); Symbol() =="EURUSD+"; OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES); double B = OrderProfit(); Alert("EURJPY = ",A,"EURUSD = ",B); }

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Price Data Structure
- www.mql5.com
This is a structure for storing the latest prices of the symbol. It is designed for fast retrieval of the most requested information about current prices. The parameters of each tick are filled in regardless of whether there are changes compared to the previous tick. Thus, it is possible to find out a...
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - The code you wrote is BS. Don't post code that won’t even compile.
- Go through the list, filter by symbol, sum OrderProfit + OrderSwap + OrderCommission.
I am sorry to break rules. Its already edited by CODE button.
Could anyone please help me to modify my code? I am really really beginer :-)
I would like to get last OrderProfit of each pair.
Here is the result I need.
As I am not real coder, you can adapt it... avoid mistakes, or present simple way, etc
Bye and wish you strong health.
#include <stdlib.mqh> double EURJPY = 0; double EURUSD = 0; double USDJPY = 0; int OnInit(){ EventSetTimer(3); } int i; void OnTimer(){ int OI = 0; while (OI<=1000){ i++; (OrderSelect(OI, SELECT_BY_POS)); if (OrderSymbol() == "EURJPY+"){ EURJPY = OrderProfit(); } if (OrderSymbol() == "EURUSD+"){ EURUSD = OrderProfit(); } if (OrderSymbol() == "USDJPY+"){ USDJPY = OrderProfit(); } OI = OI + 1; } Alert("EURJPY = ",EURJPY,"; EURUSD = ",EURUSD,"; USDJPY = ",USDJPY); }

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
Hi everyone,
I have several opened orders. Some of them are EURJPY, some of them are EURUSD.
How can I get last OrderProfit of each pair?
Thank you for any help, and sorry for possible grammar mistake, I am not native English.