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,
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.
- The question makes no sense. You select an order, and you get the symbol of that order with that function.
-
You can not use any Trade Functions until you first select an order.
- The question makes no sense. You select an order, and you get the symbol of that order with that function.
-
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...
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.
How to distinct OrderSymbol() in MQL4?
I have data:
Symbol | Type | Size
GBPUSD | Buy | 1.5
GBPUSD | Buy | 0.5
EURUSD | Sell | 1
USDJPY | Buy | 2
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.
//+------------------------------------------------------------------+ //| Haskayafxstubborn goat.mq4 | //| Copyright 2019, Haskaya Software | //| https://www.haskayayazilim.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, Haskaya Software" #property link "https://www.haskayayazilim.net" #property version "1.00" #property strict #include <Arrays\ArrayString.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class IntegerSet : public CArrayString { public: bool Add(const string element) { if(this.SearchLinear(element) < 0) return CArrayString::Add(element); return false; } }; void OnTick() { MarketEmirKontrol(); ExpertRemove(); } void MarketEmirKontrol() { IntegerSet MarketEmirler; for(int i=OrdersTotal()-1; i>=0; --i) { if(OrderSelect(i, SELECT_BY_POS)) { MarketEmirler.Add(OrderSymbol()); } } for(int i=MarketEmirler.Total()-1; i>=0; --i) { Print(MarketEmirler.At(i)); //SorgulananEmirler=MarketEmirler.SearchLinear(BekleyenEmirler.At(i)); //Print(SorgulananEmirler," ",BekleyenEmirler.At(i)); } }
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How to distinct OrderSymbol() in MQL4?
I have data:
Symbol | Type | Size
GBPUSD | Buy | 1.5
GBPUSD | Buy | 0.5
EURUSD | Sell | 1
USDJPY | Buy | 2
I want the result:
GBPUSD
EURUSD
USDJY
found one way on the internet but am i interested in any other idea?
Thanks