Home > Uncategorized > FxSharp going Mono

FxSharp going Mono

In this blog post I will tell you my experience porting my open source .NET project to Mono. It’s very easy.

FxSharp is my Expert Advisor System for MetaTrader 4 written in C#. MetaTrader is terminal used by Forex retail trader to enter the transaction. There’s a programming language called MQL. You can use it to create your own expert advisor, but it’s very ancient. Procedural and sucks ! MQL 5 is not a big different with MQL 4. It’s a object oriented language using c++ like syntax. It’s not c++. It’s only like c++. You can see a horrible codes written in this language. C# is better for developer productivity. I use Trade Platform .NET to bridge the MQL into C#. It’s very nice open source project.

First, we need to check out the source code from github.

image

Change to the directory and you will find solution file. We will build this with xbuild. Before that don’t forget to change the permission of that source code.

image

After xbuild the solution, you will find that everything is compiled fine.

image

image

But when I run it, i ‘ve got this simple and strange error message.

image

I’m very confused at the first time. Because it doesn’t tell the detail. So I do some googling and found that’s I’m using unsupported API. How do I know which one ?? Finally I found a nice tools called MoMA (The Mono Migration Analyzer)

I download and run it to analyze my application on windows.

image

Include all the assembly tobe analyzed. You can find guide using MoMA here.

image

I take a look at the report and found that there’s a problem in entry point.

image

Seems I use the spesific windows functionality here.

image

Well, I just need to comment it in the caller.

image

I run it again and voila. It’s works. My server is running on linux.

image

Ok. Now I need to connect the Expert Advisors to point to the Linux Servers. First I need to disable the firewall. I don’t want to get caught up setting one by one, so I choose to disable the firewall.

 

image

image

image

Fill the expert advisors settings. And Ok.

image

And… Boom. The program is running but seems it can’t load the assembly required for the process. Trade Platform load the assembly dynamically to App Domain. So there’s something wrong with the loading process I think. Why it can’t find the assembly…

image

Finally I found the problematic codes for loading assembly. It use hardcode to create path for the assembly.

image

I found a good explanation about the best practice for compatibility between windows and linux. Read this article.

 

image

I change the code into something like this. Using method .NET provided.

image

After push and pull from github. Running it. It’s working now !

The Quarts scheduler, parser, tcp/ip. All the functionality.

image

 

It’s very easy to run your .NET application on Linux. Mono is the answer.

It’s awesome

 

Cheers

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. March 26, 2016 at 1:08 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: