An API for .NET

 

Hi,

I know I've spoken about all of this before in other posts... but I think this would be a VERY useful addition to the scene...

I am slightly frustrated by the MQL4 language sometimes and often need to "talk" to the outside world -I have my reasons. What I would find enormously useful is the ability to write my own code in .NET and be able to hook into an API for performing trade functions and getting tick data.

The maintenance of the whole MQL4 language must be a nightmare - why not facilitate all of the user base with a very easy to use API and allow us the ability to leverage the power of languages such as VB.NET and & C#.NET along with C++ ?...

Surely this is built into the terminal somewhere anyway - I can't imagine it would be all that difficult to extract out to a nice DLL we can use ?...

Just a thought... (request even)

Cheers.

 

TheForexDevMan wrote >>

Hi,

I know I've spoken about all of this before in other posts... but I think this would be a VERY useful addition to the scene...

I am slightly frustrated by the MQL4 language sometimes and often need to "talk" to the outside world -I have my reasons. What I would find enormously useful is the ability to write my own code in .NET and be able to hook into an API for performing trade functions and getting tick data.

The maintenance of the whole MQL4 language must be a nightmare - why not facilitate all of the user base with a very easy to use API and allow us the ability to leverage the power of languages such as VB.NET and & C#.NET along with C++ ?...

Surely this is built into the terminal somewhere anyway - I can't imagine it would be all that difficult to extract out to a nice DLL we can use ?...

Just a thought... (request even)

Cheers.

I have developed some times ago easy to use .NET MT4 API and could sell it. Also could provide trial version.

API shows tooltips to all functions:


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

 
TheForexDevMan:

Hi,

I know I've spoken about all of this before in other posts... but I think this would be a VERY useful addition to the scene...

I am slightly frustrated by the MQL4 language sometimes and often need to "talk" to the outside world -I have my reasons. What I would find enormously useful is the ability to write my own code in .NET and be able to hook into an API for performing trade functions and getting tick data.

The maintenance of the whole MQL4 language must be a nightmare - why not facilitate all of the user base with a very easy to use API and allow us the ability to leverage the power of languages such as VB.NET and & C#.NET along with C++ ?...

Surely this is built into the terminal somewhere anyway - I can't imagine it would be all that difficult to extract out to a nice DLL we can use ?...

Just a thought... (request even)

Cheers.

Great !!!

SS Solutions deployed ability to execute .Net(C#) code from mql script

with data exchange gateway http://www.mttrade.net

simple and robust solution

 

Check new and robust solution http://www.mttrade.net

C# coding in mql4 script

Reason: