MQL5 calling a .NET method with a returned value

 

The article https://www.metatrader5.com/en/releasenotes/terminal/1898 has an example on how the MQL5 can call a function of c# and return a value.

I have done the short example, without success. 


My goal is to pass some values from MQL5 to a function in c# in order to do some calculations and the function to return a value to the MQL5.


C#  (64-bit)

namespace WinAI
{
    public class WinAI
    {
      
        public static   int getSignal(int s)
        {
           return  s + s;
        }
    }
}



MQL5

#import "WinAI.dll"
int getSignal(int s);

#import
int OnInit()   {   int b=5;   int c= WinAI::getSignal(b);   }


and I am getting the following error :

Cannot find 'getSignal' in 'WinAI.dll'


May I have your help, please? Thanks

 


MetaTrader 5 platform build 1930: Floating window charts and .Net libraries in MQL5
MetaTrader 5 platform build 1930: Floating window charts and .Net libraries in MQL5
  • 2018.10.26
  • MetaQuotes Software Corp.
  • www.metatrader5.com
Now you can detach financial symbol charts from the trading terminal window. This feature is convenient when using multiple monitors. Thus, you may set the main platform window on one monitor to control your account state, and move your charts to the second screen to observe the market situation. To detach a chart from the terminal, disable the...
 
Giannos Antoniou: I am getting the following error : Cannot find 'getSignal' in 'WinAI.dll'
c= WinAI::getSignal(b);   }

Perhaps because there is no getSignal in namespace WinAI

 
Hi @Giannos Antoniou, the capabilities of MT5 that handle the .NET imports are not that mature in my experience. DLL name must be the same like namespace and so on. In that case I would recommand not to choose the same name for the namespace and the class itself. The rest looks quite good.