Return C# struct to MQL via DLL
lastpunisher:
Try to pass a ref to the structure
Hi,
I would expect the following code to work. But MQL giving "'Order' - illegal returned type".
Any idea why?
Best Regards,
Hendrik
Because MQL supports only fundamental types as return values.
Convert structure to string and then send string, receive string convert back to structure.
Converting to string is inconsistent. Do not use strings for binary data.
Strings have a stop byte. It won't work due to length detection issues.
Hi,
I would expect the following code to work. But MQL giving "'Order' - illegal returned type".
Any idea why?
MQL struct order { bool isBuy; bool isSell; double takeProfit; double stopLoss; }; #import "ExpertAdvisor.dll" order Order(); #import //| | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { order test = Order(); }Best Regards,
Hendrik