How can I get last OrderProfit of each pair?

To add comments, please log in or register
PavelLeva
13
PavelLeva  

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.

PavelLeva
13
PavelLeva  
#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
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...
William Roeder
20808
William Roeder  
  1. 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

  2. The code you wrote is BS. Don't post code that won’t even compile.
  3. Go through the list, filter by symbol, sum OrderProfit + OrderSwap + OrderCommission.
PavelLeva
13
PavelLeva  

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.

PavelLeva
13
PavelLeva  

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);
}
To add comments, please log in or register