call ordersend from within c++?

 

Hello

 When using c++, is it possible to access the mql methods from within the c++ code? Or is it only possible to pass primitives between the c++ and mql?

 

To clarify, I am wanting the ability to call orderSend in c++ code.

 

Thanks 

 

You have to get the MQL code to initiate the process. Check here for a solution in C# :  https://github.com/jseparovic/MQL4CSharp

It's quite simple really, just makes use of the onTimer function and launches the C# code in it's own thread, so it can block while the MQL function completes and sets the result 

 
jseparovic:

You have to get the MQL code to initiate the process. Check here for a solution in C# :  https://github.com/jseparovic/MQL4CSharp

It's quite simple really, just makes use of the onTimer function and launches the C# code in it's own thread, so it can block while the MQL function completes and sets the result 

Thanks jseparovic 

 You have a very interesting project there!

Whats the story of the AlgoTrader github repo? Seems someone didnt like you using that! 

 
Terminal calls start. Mt4 calls the DLL. The DLL returns a command to open an order. Mt4 calls OrderSend. No extra threads required.
 
magick93:

Thanks jseparovic 

 You have a very interesting project there!

Whats the story of the AlgoTrader github repo? Seems someone didnt like you using that! 

I just noticed that. I hadn't even looked at it yet. Seems as though they retracted their opensource
 
WHRoeder:
Terminal calls start. Mt4 calls the DLL. The DLL returns a command to open an order. Mt4 calls OrderSend. No extra threads required.

How do you get the command response back though within the same C# call?

So C# call to OrderSend waits until MT4 detects the command and sets the result. It must be in a separate thread if it is blocking.

 
jseparovic: How do you get the command response back though within the same C# call?
There is no "same C# call." You call the DLL it returns values (function value or parameters passed by referenced) The DLL call is over; check the results and do the OrderSend.
 
WHRoeder:
There is no "same C# call." You call the DLL it returns values (function value or parameters passed by referenced) The DLL call is over; check the results and do the OrderSend.

"There is no "same C# call.""??  haha, yes there is!

You are missing the point, that it the goal of my api!  The idea of this library it to write code purely in C#, and never touch MQL.

So therefore if I want to call OrderSend in C#, I must have it in a separate thread, as multiple DLL calls from MT4 need to be made during the start and end of the C# method. The C# method blocks, while MT4 does it's stuff.

I'm just offering a different approach. no need to get all black and white about it

 
magick93:

Thanks jseparovic 

 You have a very interesting project there!

Whats the story of the AlgoTrader github repo? Seems someone didnt like you using that! 

hey magick,

I just committed a bunch of the framework stuff. Checkout https://github.com/jseparovic/MQL4CSharp/blob/master/MQL4CSharp/UserDefined/Strategy/MaCrossStrategy.cs

This is the basic idea I'm going for. All the bits should be reusable, and strategies simple to write.

 

Cheers 

 

I just tested a REST API too and it works nicely. In the next commit you will be able to run MQL commands from REST. Then I'll add a websockets API for events and onTick RatesInfo. Get some pretty JS frontends happening. 

 
jseparovic:

I just tested a REST API too and it works nicely. In the next commit you will be able to run MQL commands from REST. Then I'll add a websockets API for events and onTick RatesInfo. Get some pretty JS frontends happening. 

http://screencast.com/t/L99aBY9LiRU
Reason: