# How To Distinct OrderSymbol() In MQL4

137

How to distinct  OrderSymbol()  in MQL4?

I have data:

Symbol | Type | Size

EURUSD | Sell | 1

I want the result:

GBPUSD

EURUSD

USDJY

found one way on the internet but am i interested in any other idea?

Thanks

225

Hi Milan,

what do you think of this solution:

```        string str_1 = "GBPUSD | Buy | 1.5 ";
string str_2[];
string str_3;

StringSplit(str_1, '|', str_2);
str_3 = StringTrimRight(str_2[0]);
```

Best regards,

137

Werner Klehr:

Hi Milan,

what do you think of this solution:

Best regards,

Hi Werner,

my example is not a string, it is OrderSymbol() function.

It is necessary to get a unique symbol from that function that returns the symbols.

137

I need to get unique symbols as the end result.

like this:

EURUSD

GBPUSD

USDCHF

25060

Milan Zivanovic: my example is not a string, it is OrderSymbol() function.
1. The question makes no sense. You select an order, and you get the symbol of that order with that function.
2. You can not use any Trade Functions until you first select an order.

137

William Roeder:
1. The question makes no sense. You select an order, and you get the symbol of that order with that function.
2. You can not use any Trade Functions until you first select an order.

Of course I selected the order first.

```   int total = ObjectsTotal();
for (int i = 0; i < total; i++)
{
if (!OrderSelect(i, SELECT_BY_POS)) continue;

string cp = OrderSymbol();
}```

This is how I get double symbols because there are several open orders with the same symbol.

My question is how to distinct them? Like group by...

7134

Milan Zivanovic:

Of course I selected the order first.

This is how I get double symbols because there are several open orders with the same symbol.

My question is how to distinct them? Like group by...

There's no easy way to do that like in SQL.

Add the symbols to a string array and before each add check if the symbol is already in the array.

2551

Milan Zivanovic:

How to distinct  OrderSymbol()  in MQL4?

I have data:

Symbol | Type | Size

EURUSD | Sell | 1

I want the result:

GBPUSD

EURUSD

USDJY

found one way on the internet but am i interested in any other idea?

Thanks

This can be done simply as follows. Picture of before and in order is attached.

```//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict

#include <Arrays\ArrayString.mqh>

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class IntegerSet : public CArrayString
{
public:
{
if(this.SearchLinear(element) < 0)
return false;
}
};
void OnTick()
{

MarketEmirKontrol();
ExpertRemove();
}

void MarketEmirKontrol()
{
IntegerSet MarketEmirler;

for(int i=OrdersTotal()-1; i>=0; --i)
{
if(OrderSelect(i, SELECT_BY_POS))
{

}
}
for(int i=MarketEmirler.Total()-1; i>=0; --i)
{
Print(MarketEmirler.At(i));
//SorgulananEmirler=MarketEmirler.SearchLinear(BekleyenEmirler.At(i));
//Print(SorgulananEmirler," ",BekleyenEmirler.At(i));
}

}
```
137

Mehmet Bastem:

This can be done simply as follows. Picture of before and in order is attached.

Yes, this is the solution I was looking for.

Thank you Mehmet.