Selecting symbols on History function that contains specific letters.

 

Hi folks, 


I would like to select in Deals or Orders History any symbol that begins with "EUR" letters. 

Even if my EA is on "EURUSD" chart, I would like to get "history deals" from "EURCAD" for example, or any symbol that begins with "EUR..."

The following is my code to select only the Symbol on chart. How can I do this?


double TodayProfit()
  {
//---
   datetime history=iTime(Symbol(),PERIOD_D1,0); 
   double profit_today=0;
   HistorySelect(history,TimeCurrent()); //Selecting history period 
   int deals=HistoryDealsTotal(); //Getting all deals from selected period
   for(int i=0;i<deals; i++)
         {
          ulong deal_ticket=HistoryDealGetTicket(i);
          if(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)==Symbol()) //Filtering only deals from Symbol on chart.
               {
                if(HistoryDealGetInteger(deal_ticket,DEAL_ENTRY)==DEAL_ENTRY_OUT) 
                  profit_today+=HistoryDealGetDouble(deal_ticket,DEAL_PROFIT); //Getting all profit today
               }
           
         }
   return profit_today; 
  
  }
 
Guilherme Mendonca:

Hi folks, 


I would like to select in Deals or Orders History any symbol that begins with "EUR" letters. 

Even if my EA is on "EURUSD" chart, I would like to get "history deals" from "EURCAD" for example, or any symbol that begins with "EUR..."

The following is my code to select only the Symbol on chart. How can I do this?


With SymbolInfoString(), you can access BASE_CURRENCY, PROFIT_CURRENCY and MARGIN_CURRENCY. Read on the documentation and you'll find your answer!
 
La_patates:
With SymbolInfoString(), you can access BASE_CURRENCY, PROFIT_CURRENCY and MARGIN_CURRENCY. Read on the documentation and you'll find your answer!
I think I was not very specific, specially the example.
I’m not trying to find some currency data.
As I’m trading futures of stock markets, I’m looking for something like.

if(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)==DXY***)

So, I would like to receive all data from all symbols that starts with “DXY”.
The purpose of this is because sometimes I’m trading multiple Futures CFDs with different expiration dates.
Check the attach to seen an example.
 

instead of  if(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)==DXY***)

try 

string abc = HistoryDealGetString(deal_ticket,DEAL_SYMBOL) ;

if(StringFind(abc,"DXY"){

//whatever you want to do 

}

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
Deal Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Douglas Prager:

instead of  if(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)==DXY***)

try 

string abc = HistoryDealGetString(deal_ticket,DEAL_SYMBOL) ;

if(StringFind(abc,"DXY"){

//whatever you want to do on

}


Thanks.
That’s I was looking for! 
Reason: