This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

Easy to use MT4 .NET API


Back to topics list
avatar
8
timurila 2009.08.11 20:20 

I want to present fallowing API's(each supports tooltips and debugging in Visual Studio.):

1 .NET executable to MT4 API - allows communicating with MT4 from .NET executable. Back testing in MT4 is not possible with this API, just real time trading. API good for bridging between MT4 and another platforms. Also could be usefull for people who already have the system written on non MQL language and want to trade it on MT4 without porting to MQL. Programmer just uses special class to call any MQL functions(trading, indicators, checkup, etc).
2 .NET Expert Advisor for MT4 API - allows to create Expert Advisor on powerfull .NET. Back testing avaliable. Programmer need to create class that implements special interface. As result his class will get init, deinit, start signals and inside this class programmer could call any MQL functions.

3 .NET classes from MT4 API - appropriate for people who creates EA's on MQL but want to operate with .NET classes and call their methods from MQL Editor.


Tim

timurila@gmail.com
avatar
8
timurila 2009.08.11 20:21 

Trial version of .NET executable to MT4 API attached. Instructions, sample VB and C# projects included in archive.



ToolTip

C# example:

using System;
using System.Collections.Generic;
using System.Text;
using MetaTraderApi;

namespace TestClient
{
	public class ExtendedMT : MetaTrader
	{
		public ExtendedMT(string channelName)
			: base(channelName)
		{
		}

		public int buy(string symbol)
		{
			double ask = MarketInfo(symbol, InfoMode.ASK);
			int ticket = OrderSend(symbol, Op.BUY, 1, ask, 0, 0, 0);
			if(ticket<=0)
				throw new Exception(GetLastErrorDescription());
			return ticket;
		}

		public int sell(string symbol)
		{
			double bid = MarketInfo(symbol, InfoMode.BID );
			int ticket = OrderSend(symbol, Op.SELL, 1, bid, 0, 0, 0);
			if (ticket <= 0)
				throw new Exception(GetLastErrorDescription());
			return ticket;
		}

		public void closeAll()
		{
			while (OrdersTotal()>0)
			{
				if(OrderSelect(0, SelectMode.BY_POS))
				{
					double price = 0;
					if(OrderType() == Op.BUY )
						price = MarketInfo(OrderSymbol(), InfoMode.BID);
					if(OrderType() == Op.SELL)
						price = MarketInfo(OrderSymbol(), InfoMode.ASK);
					if(!OrderClose(OrderTicket(), OrderLots(), price,0))
						throw new Exception(GetLastErrorDescription());
				}
				else
					throw new Exception(GetLastErrorDescription());
			}
		}

		public void printOrders()
		{
			int count = OrdersTotal();
			for (int i = 0; i < count; i++)
			{
				if (OrderSelect(i, SelectMode.BY_POS))
					Console.WriteLine(OrderSymbol() + " " + OrderExpiration());
				else
					throw new Exception(GetLastErrorDescription());
			}
		}

		public int buyPending(string symbol)
		{
			double ask = MarketInfo(symbol, InfoMode.ASK);
			double point = MarketInfo(symbol, InfoMode.POINT);
			double price = ask + 10 * point;
			int ticket = OrderSend(symbol, Op.BUYSTOP, 1, price, 0, 0, 0, 
				null, 0, DateTime.Now.AddHours(1));
			if (ticket <= 0)
				throw new Exception(GetLastErrorDescription());
			return ticket;
		}
	}
}


Regards

Tim

timurila@gmail.com
Attached files:
  Reduced_MT4_.NET_API_Trial_1.0.1_2.zip (2 417.39 KB)
avatar
4
nickfx 2009.08.12 09:25 

Disappointed...

It's just using a MT4 side EA as a proxy... Ugly solution I'd say.

avatar
8
timurila 2009.08.12 16:17 
nickfx :

Disappointed...

It's just using a MT4 side EA as a proxy... Ugly solution I'd say.

Thanks for the interest. What kind of API(or way of realization) you would be glad to see?

avatar
8
timurila 2009.08.17 18:19 

New 1.0.3 version of MT4 .NET API avaliable.

Fixed problem with tooltips.

Previuosly were realized just trading and checkup functions. From now account functions also available.


Tim

timurila@gmail.com

www.tradingapi.net

Attached files:
  MT4_.NET_API_1.0.3_Trial.zip (2 431.99 KB)
avatar
8
timurila 2009.09.07 18:43 

Latest 1.0.4 version attached.


Tim

timurila@gmail.com

www.tradingapi.net

Attached files:
  MT4_.NET_API_1.0.4_Trial.zip (2 433.03 KB)
avatar
8
timurila 2009.09.15 09:27 

New 1.0.7 version.

Was fixed problem with contolling several MT4 plaforms from one application.


Tim

timurila@gmail.com

www.tradingapi.net

Attached files:
  MT4_.NET_API_1.0.7_Trial.zip (2 433.60 KB)
avatar
8
timurila 2009.09.23 23:13 

New 1.1.1 version available to download.

New Common and Indicator function groups were added. See documentation for additional details.


Tim

timurila@gmail.com

www.tradingapi.net

Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets