New API MetaTrader 4 AVAILABLE - page 6

 
yewnix:

I don't understand something here..

I can do Order Sends all day long..

However I'm having a big issue doing a OrderClose..


Can you please give an example on these.


I really don't think its my .NET wrapper DLL.

Hi yewnix!


You can take a look on <Program Files>\TradeZone\TZMT4API\Developer\Short_Sample_MQL4.zip


this simple mql code, close all open orders, once you include <orderproxy.mqh>


   int hAccount = TZ_LogIn(Login, Password, Server, "", "", "", "");

   int Total    = TZ_OrdersTotal();


   for(i=0;i<Total;i++)

   {

      TZ_OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

      TZ_OrderClose(TZ_OrderTicket(), TZ_OrderLots(), TZ_OrderClosePrice(), 3);

   } 

   

Kindest regards.

 
TradeZone:

Hi yewnix!


You can take a look on C:\Arquivos de programas\TradeZone\TZMT4API\Developer\Short_Sample_MQL4.zip


this simple mql code, close all open orders, once you include <orderproxy.mqh>


int hAccount = TZ_LogIn(Login, Password, Server, "", "", "", "");

int Total = TZ_OrdersTotal();


for(i=0;i<Total;i++)

{

TZ_OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

TZ_OrderClose(TZ_OrderTicket(), TZ_OrderLots(), TZ_OrderClosePrice(), 3);

}

Kindest regards.

I'm trying to do this in C#.

I've taken your functions and wrote a dll wrapper for .NET

ie:


double askprice = MT4ApiNet.MarketInfo_MT4(h, "GBPUSD", (int)MT4ApiNet.MarketInfoType.MODE_ASK)

MT4ApiNet.OrderSend_MT4(h, "GBPUSD", (int)MT4ApiNet.OrderType.OP_BUY, 1, askprice, 3, (askprice - 0.0050), (askprice + 0.0050), "My Program", 100, 0);


This works perfectly. This order shows up perfectly.

Now.. If I get the order# from MetaTrader(using 1234 as order# for example)


MT4ApiNet.OrderClose_MT4(h, 1234, 1, MT4ApiNet.OrderClosePrice_MT4(h,1234), 20);


This does not cancel the order...

Even if i cycle through the orders.. and do a MT4ApiNet.OrderGet_MT4 it still does not work

 

FYI.

After doing the OrderClose, if I getlast error..

MessageBox.Show(MT4ApiNet.ErrorDescription_MT4(MT4ApiNet.GetLastError_MT4(h)));


This return General Erro



Can you atleast just show a proper OrderClose in delphi ?

Even in delphi my code hangs

 
TradeZone:

Hi juso,


<Program Files>\TradeZone\TZMT4API\Developer\MetaTrader4 API.txt contains what do you want.


Kindest regards.

Hi TradeZone


thanx for prompt response. Last time I was doing c++ development actively was 8 years ago and by that time one needed to have *.h and *.lib of the dll to be able to excercise api naturally. In case you have *.h file and don't have *.lib you still can do it by resolving function address dynamically, though the process is more tedious. So, I can create the *.h file myself though *.lib is still missing. May be, there is an easy way of creating lib thingy from dll itself that I'm not aware of. 


Take care

Juso

 

TradeZone,


Could you please post a working sample OrderClose_MT4 command being sent from Delphi application.

As stated earlier I can not get this working.


Thanks!

 
bump.. bump..
 

Well, because I haven't received a response to this I started digging into how your DLL actually works.

Pretty good idea actually.

Load up 10 charts each attaching to a different EA.

These EAs run and create files in the experts/files directory.

DLL reads these files back in to show data in your programmed app.

EA checks for the existence of files(produced by the DLL calls) and if they exist process transactions then create other files to give response data back then delete the file created by the DLL so we know the transaction has either completed or failed.


If I'm not mistaken your Handle returned back from the Login_MT4 command is just an index to the randomly generated directory name. This way you know which terminal.exe process to control and where to place your generated files at.


I could be wrong with all this, I just want to fix the OrderClose issue I've been having...


However instead of creating files over and over again... I'd highly recommend using Memory Mapping(Create / Open Memory Map based on Pair Name_Handle)

Good work by the way.. just which you could tell me about the OrderClose so I don't have to code my own EAs and the Memory Map DLL interface.


There you have it guys, my analysis on this API.


Cheers!

 

Guys,

I have an integration like this working nicely and tested (not this code). It is done trough an expert, and exposes functionality trough a C++/ Managed C++ to a .NET module. It allows smooth trades management, reports errors, gives real time quotes, etc. Communication is trough TCP, so its fast and reliable.

It will be posted fully free open source as a part of a new open source trading platform (.NET based, it can use MT4 to receive data or perform orders). You can choose to use the platform, or simply a small part of the integration - it is up to you.

If you are interested put your hands up, and I will give you more details. :)

The platform is planned to launch in a few days time (approx. 15.Oct).

 

Peer2k,


Nice, ya I thought about using TCP instead of Memory Mapping.

If you like to send a link to the code I wouldn't mind looking at it.

That is up to you though :)


Cheers!

yewnix@gmail.com

 
hey, peer2k, that would be very cool, please post me with the details, yuryrub@gmail.com.
Reason: