No way with MQL.
It's C++ based and it does not have anything similar to Linq.
Possible solutions:
- only solution using only Mql4: "add multiple loops but that'd be very ugly way". I agree that it is ugly.
- create C# dll and then send the data to the dll, do you Linq processing there and return result. Cumbersome, ugly, but can be done.
- look at the .Net integration for Metatrader 5, maybe you can make it work with Mql4 (I didn't try) - chances that this will work are pretty slim, if it works, it is unsupported, but it might be an elegant solution
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
I have an array of objects such as:
class RunningOrder {
private:
public:
datetime OpenDate;
string Market;
double RiskAmount;
};
RunningOrder _runningOrders[];
How do I group the objects by one of the properties e.g. the Market property?
Basically, I'd need the equivalent of this C# code in MQL?
_runningOrders.GroupBy(r => r.Market, a => a.Sum(i => i.RiskAmount)) that should return:
GBPUSD, 1000
EURUSD, 500
I can add multiple loops but that'd be very ugly way, is there any good recommend way in MQL 4 to group by?
Thank you