mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-15 11:48:09 +00:00
Added projects MtApi4 and MtApi5
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
static class ExtensionMethods
|
||||
{
|
||||
#region Event Methods
|
||||
public static void FireEvent(this EventHandler eventHandler, object sender)
|
||||
{
|
||||
if (eventHandler != null)
|
||||
{
|
||||
eventHandler(sender, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FireEvent<T>(this EventHandler<T> eventHandler, object sender, T e)
|
||||
where T : EventArgs
|
||||
{
|
||||
if (eventHandler != null)
|
||||
{
|
||||
eventHandler(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlBookInfo
|
||||
{
|
||||
public MqlBookInfo(ENUM_BOOK_TYPE type, double price, long volume)
|
||||
{
|
||||
this.type = type;
|
||||
this.price = price;
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public ENUM_BOOK_TYPE type { get; private set; } // Order type from ENUM_BOOK_TYPE enumeration
|
||||
public double price { get; private set; } // Price
|
||||
public long volume { get; private set; } // Volume
|
||||
}
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlRates
|
||||
{
|
||||
public MqlRates(DateTime time, double open, double high, double low, double close, long tick_volume, int spread, long real_volume)
|
||||
{
|
||||
this.time = time;
|
||||
this.open = open;
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
this.close = close;
|
||||
this.tick_volume = tick_volume;
|
||||
this.spread = spread;
|
||||
this.real_volume = real_volume;
|
||||
}
|
||||
|
||||
public DateTime time { get; private set; } // Period start time
|
||||
public double open { get; private set; } // Open price
|
||||
public double high { get; private set; } // The highest price of the period
|
||||
public double low { get; private set; } // The lowest price of the period
|
||||
public double close { get; private set; } // Close price
|
||||
public long tick_volume { get; private set; } // Tick volume
|
||||
public int spread { get; private set; } // Spread
|
||||
public long real_volume { get; private set; } // Trade volume
|
||||
}
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTick
|
||||
{
|
||||
public MqlTick(DateTime time, double bid, double ask, double last, ulong volume)
|
||||
{
|
||||
this.time = time;
|
||||
this.bid = bid;
|
||||
this.ask = ask;
|
||||
this.last = last;
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public DateTime time { get; private set; } // Time of the last prices update
|
||||
public double bid { get; private set; } // Current Bid price
|
||||
public double ask { get; private set; } // Current Ask price
|
||||
public double last { get; private set; } // Price of the last deal (Last)
|
||||
public ulong volume { get; private set; } // Volume for the current Last price
|
||||
}
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeCheckResult
|
||||
{
|
||||
public uint Retcode { get; private set; } // Reply code
|
||||
public double Balance { get; private set; } // Balance after the execution of the deal
|
||||
public double Equity { get; private set; } // Equity after the execution of the deal
|
||||
public double Profit { get; private set; } // Floating profit
|
||||
public double Margin { get; private set; } // Margin requirements
|
||||
public double Margin_free { get; private set; } // Free margin
|
||||
public double Margin_level { get; private set; } // Margin level
|
||||
public string Comment { get; private set; } // Comment to the reply code (description of the error)
|
||||
|
||||
public MqlTradeCheckResult(uint retcode
|
||||
, double balance
|
||||
, double equity
|
||||
, double profit
|
||||
, double margin
|
||||
, double margin_free
|
||||
, double margin_level
|
||||
, string comment)
|
||||
{
|
||||
Retcode = retcode;
|
||||
Balance = balance;
|
||||
Equity = equity;
|
||||
Profit = profit;
|
||||
Margin = margin;
|
||||
Margin_free = margin_free;
|
||||
Margin_level = margin_level;
|
||||
Comment = comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeRequest
|
||||
{
|
||||
public ENUM_TRADE_REQUEST_ACTIONS Action { get; set; } // Trade operation type
|
||||
public uint Magic { get; set; } // Expert Advisor ID (magic number)
|
||||
public uint Order { get; set; } // Order ticket
|
||||
public string Symbol { get; set; } // Trade symbol
|
||||
public double Volume { get; set; } // Requested volume for a deal in lots
|
||||
public double Price { get; set; } // Price
|
||||
public double Stoplimit { get; set; } // StopLimit level of the order
|
||||
public double Sl { get; set; } // Stop Loss level of the order
|
||||
public double Tp { get; set; } // Take Profit level of the order
|
||||
public uint Deviation { get; set; } // Maximal possible deviation from the requested price
|
||||
public ENUM_ORDER_TYPE Type { get; set; } // Order type
|
||||
public ENUM_ORDER_TYPE_FILLING Type_filling { get; set; } // Order execution type
|
||||
public ENUM_ORDER_TYPE_TIME Type_time { get; set; } // Order expiration type
|
||||
public DateTime Expiration { get; set; } // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
|
||||
public string Comment { get; set; } // Order comment
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeResult
|
||||
{
|
||||
public MqlTradeResult(uint retcode, ulong deal, ulong order, double volume, double price, double bid, double ask, string comment, uint request_id)
|
||||
{
|
||||
Retcode = retcode;
|
||||
Deal = deal;
|
||||
Order = order;
|
||||
Volume = volume;
|
||||
Price = price;
|
||||
Bid = bid;
|
||||
Ask = ask;
|
||||
Comment = comment;
|
||||
Request_id = request_id;
|
||||
}
|
||||
|
||||
public uint Retcode { get; private set; } // Operation return code
|
||||
public ulong Deal { get; private set; } // Deal ticket, if it is performed
|
||||
public ulong Order { get; private set; } // Order ticket, if it is placed
|
||||
public double Volume { get; private set; } // Deal volume, confirmed by broker
|
||||
public double Price { get; private set; } // Deal price, confirmed by broker
|
||||
public double Bid { get; private set; } // Current Bid price
|
||||
public double Ask { get; private set; } // Current Ask price
|
||||
public string Comment { get; private set; } // Broker comment to operation (by default it is filled by the operation description)
|
||||
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
|
||||
}
|
||||
}
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5ConnectionEventArgs: EventArgs
|
||||
{
|
||||
public Mt5ConnectionState Status { get; private set; }
|
||||
public String ConnectionMessage { get; private set; }
|
||||
|
||||
public Mt5ConnectionEventArgs(Mt5ConnectionState status, string message)
|
||||
{
|
||||
Status = status;
|
||||
ConnectionMessage = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
namespace MtApi5
|
||||
{
|
||||
public enum Mt5ConnectionState
|
||||
{
|
||||
Connecting,
|
||||
Connected,
|
||||
Disconnected,
|
||||
Failed
|
||||
}
|
||||
}
|
||||
Executable
+333
@@ -0,0 +1,333 @@
|
||||
namespace MtApi5
|
||||
{
|
||||
public enum ENUM_TRADE_REQUEST_ACTIONS
|
||||
{
|
||||
TRADE_ACTION_DEAL = 1, //Place a trade order for an immediate execution with the specified parameters (market order)
|
||||
TRADE_ACTION_PENDING = 5, //Place a trade order for an immediate execution with the specified parameters (market order)
|
||||
TRADE_ACTION_SLTP = 6, //Place a trade order for an immediate execution with the specified parameters (market order)
|
||||
TRADE_ACTION_MODIFY = 7, //Place a trade order for an immediate execution with the specified parameters (market order)
|
||||
TRADE_ACTION_REMOVE = 8 //Place a trade order for an immediate execution with the specified parameters (market order)
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_TYPE
|
||||
{
|
||||
ORDER_TYPE_BUY = 0, //Market Buy order
|
||||
ORDER_TYPE_SELL = 1, //Market Sell order
|
||||
ORDER_TYPE_BUY_LIMIT = 2, //Buy Limit pending order
|
||||
ORDER_TYPE_SELL_LIMIT = 3, //Sell Limit pending order
|
||||
ORDER_TYPE_BUY_STOP = 4, //Buy Stop pending order
|
||||
ORDER_TYPE_SELL_STOP = 5, //Sell Stop pending order
|
||||
ORDER_TYPE_BUY_STOP_LIMIT = 6, //Upon reaching the order price, a pending Buy Limit order is places at the StopLimit price
|
||||
ORDER_TYPE_SELL_STOP_LIMIT = 7, //Upon reaching the order price, a pending Sell Limit order is places at the StopLimit price
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_TYPE_FILLING
|
||||
{
|
||||
ORDER_FILLING_FOK = 0,
|
||||
ORDER_FILLING_IOC = 1,
|
||||
ORDER_FILLING_RETURN = 2
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_TYPE_TIME
|
||||
{
|
||||
ORDER_TIME_GTC = 0,
|
||||
ORDER_TIME_DAY = 1,
|
||||
ORDER_TIME_SPECIFIED = 2,
|
||||
ORDER_TIME_SPECIFIED_DAY = 3
|
||||
}
|
||||
|
||||
public enum ENUM_POSITION_PROPERTY_DOUBLE
|
||||
{
|
||||
POSITION_VOLUME = 3, //Position volume
|
||||
POSITION_PRICE_OPEN = 4, //Position open price
|
||||
POSITION_SL = 6, //Stop Loss level of opened position
|
||||
POSITION_TP = 7, //Take Profit level of opened position
|
||||
POSITION_PRICE_CURRENT = 5, //Current price of the position symbol
|
||||
POSITION_COMMISSION = 8, //Commission
|
||||
POSITION_SWAP = 9, //Cumulative swap
|
||||
POSITION_PROFIT = 10 //Current profit
|
||||
}
|
||||
|
||||
public enum ENUM_POSITION_PROPERTY_INTEGER
|
||||
{
|
||||
POSITION_TIME = 1, //Position open time
|
||||
POSITION_TYPE = 2, //Position type
|
||||
POSITION_MAGIC = 12, //Position magic number
|
||||
POSITION_IDENTIFIER = 13 //Position identifier is a unique number that is assigned to every newly opened position and doesn't change during the entire lifetime of the position. Position turnover doesn't change its identifier.
|
||||
}
|
||||
|
||||
public enum ENUM_POSITION_TYPE
|
||||
{
|
||||
POSITION_TYPE_BUY = 0, //Buy
|
||||
POSITION_TYPE_SELL = 1 //Sell
|
||||
}
|
||||
|
||||
public enum ENUM_POSITION_PROPERTY_STRING
|
||||
{
|
||||
POSITION_SYMBOL = 0, //Symbol of the position
|
||||
POSITION_COMMENT = 11 //Position comment
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_PROPERTY_DOUBLE
|
||||
{
|
||||
ORDER_VOLUME_INITIAL = 7, //Order initial volume
|
||||
ORDER_VOLUME_CURRENT = 8, //Order current volume
|
||||
ORDER_PRICE_OPEN = 9, //Price specified in the order
|
||||
ORDER_SL = 12, //Stop Loss value
|
||||
ORDER_TP = 13, //Take Profit value
|
||||
ORDER_PRICE_CURRENT = 10, //The current price of the order symbol
|
||||
ORDER_PRICE_STOPLIMIT = 11 //The Limit order price for the StopLimit order
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_PROPERTY_STRING
|
||||
{
|
||||
ORDER_SYMBOL = 0, //Symbol of the order
|
||||
ORDER_COMMENT = 16 //Order comment
|
||||
}
|
||||
|
||||
public enum ENUM_ORDER_PROPERTY_INTEGER
|
||||
{
|
||||
ORDER_TIME_SETUP = 1, //Order setup time
|
||||
ORDER_TYPE = 4, //Order type
|
||||
ORDER_STATE = 14, //Order state
|
||||
ORDER_TIME_EXPIRATION = 2, //Order expiration time
|
||||
ORDER_TIME_DONE = 3, //Order execution or cancellation time
|
||||
ORDER_TYPE_FILLING = 5, //Order filling type
|
||||
ORDER_TYPE_TIME = 6, //Order lifetime
|
||||
ORDER_MAGIC = 15, //ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)
|
||||
ORDER_POSITION_ID = 17 //Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of exactly this position is set to the executed order at this moment.
|
||||
}
|
||||
|
||||
public enum ENUM_DEAL_PROPERTY_DOUBLE
|
||||
{
|
||||
DEAL_VOLUME = 5,
|
||||
DEAL_PRICE = 6,
|
||||
DEAL_COMMISSION = 7,
|
||||
DEAL_SWAP = 8,
|
||||
DEAL_PROFIT = 9
|
||||
}
|
||||
|
||||
public enum ENUM_DEAL_PROPERTY_STRING
|
||||
{
|
||||
DEAL_SYMBOL = 0,
|
||||
DEAL_COMMENT = 10
|
||||
}
|
||||
|
||||
public enum ENUM_DEAL_TYPE
|
||||
{
|
||||
DEAL_TYPE_BUY = 0,
|
||||
DEAL_TYPE_SELL = 1,
|
||||
DEAL_TYPE_BALANCE = 2,
|
||||
DEAL_TYPE_CREDIT = 3,
|
||||
DEAL_TYPE_CHARGE = 4,
|
||||
DEAL_TYPE_CORRECTION = 5,
|
||||
DEAL_TYPE_BONUS = 6,
|
||||
DEAL_TYPE_COMMISSION = 7,
|
||||
DEAL_TYPE_COMMISSION_DAILY = 8,
|
||||
DEAL_TYPE_COMMISSION_MONTHLY = 9,
|
||||
DEAL_TYPE_COMMISSION_AGENT_DAILY = 10,
|
||||
DEAL_TYPE_COMMISSION_AGENT_MONTHLY = 11,
|
||||
DEAL_TYPE_INTEREST = 12,
|
||||
DEAL_TYPE_BUY_CANCELED = 13,
|
||||
DEAL_TYPE_SELL_CANCELED = 14
|
||||
}
|
||||
|
||||
public enum ENUM_DEAL_ENTRY
|
||||
{
|
||||
DEAL_ENTRY_IN = 0,
|
||||
DEAL_ENTRY_OUT = 1,
|
||||
DEAL_ENTRY_INOUT = 2,
|
||||
DEAL_ENTRY_STATE = 255
|
||||
}
|
||||
|
||||
public enum ENUM_DEAL_PROPERTY_INTEGER
|
||||
{
|
||||
DEAL_ORDER = 1,
|
||||
DEAL_TIME = 2,
|
||||
DEAL_TYPE = 3,
|
||||
DEAL_ENTRY = 4,
|
||||
DEAL_MAGIC = 11,
|
||||
DEAL_POSITION_ID = 12
|
||||
}
|
||||
|
||||
public enum ENUM_ACCOUNT_INFO_INTEGER
|
||||
{
|
||||
ACCOUNT_LOGIN = 0,
|
||||
ACCOUNT_TRADE_MODE = 32,
|
||||
ACCOUNT_LEVERAGE = 35,
|
||||
ACCOUNT_LIMIT_ORDERS = 47,
|
||||
ACCOUNT_MARGIN_SO_MODE = 44,
|
||||
ACCOUNT_TRADE_ALLOWED = 33,
|
||||
ACCOUNT_TRADE_EXPERT = 34
|
||||
}
|
||||
|
||||
public enum ENUM_ACCOUNT_INFO_DOUBLE
|
||||
{
|
||||
ACCOUNT_BALANCE = 37,
|
||||
ACCOUNT_CREDIT = 38,
|
||||
ACCOUNT_PROFIT = 39,
|
||||
ACCOUNT_EQUITY = 40,
|
||||
ACCOUNT_MARGIN = 41,
|
||||
ACCOUNT_FREEMARGIN = 42,
|
||||
ACCOUNT_MARGIN_LEVEL = 43,
|
||||
ACCOUNT_MARGIN_SO_CALL = 45,
|
||||
ACCOUNT_MARGIN_SO_SO = 46
|
||||
}
|
||||
|
||||
public enum ENUM_ACCOUNT_INFO_STRING
|
||||
{
|
||||
ACCOUNT_NAME = 1,
|
||||
ACCOUNT_SERVER = 3,
|
||||
ACCOUNT_CURRENCY = 36,
|
||||
ACCOUNT_COMPANY = 2
|
||||
}
|
||||
|
||||
public enum ENUM_ACCOUNT_TRADE_MODE
|
||||
{
|
||||
ACCOUNT_TRADE_MODE_DEMO = 0,
|
||||
ACCOUNT_TRADE_MODE_CONTEST = 1,
|
||||
ACCOUNT_TRADE_MODE_REAL = 2
|
||||
}
|
||||
|
||||
public enum ENUM_ACCOUNT_STOPOUT_MODE
|
||||
{
|
||||
ACCOUNT_STOPOUT_MODE_PERCENT = 0,
|
||||
ACCOUNT_STOPOUT_MODE_MONEY = 1
|
||||
}
|
||||
|
||||
public enum ENUM_TIMEFRAMES
|
||||
{
|
||||
PERIOD_CURRENT = 0,
|
||||
PERIOD_M1 = 1,
|
||||
PERIOD_M2 = 2,
|
||||
PERIOD_M3 = 3,
|
||||
PERIOD_M4 = 4,
|
||||
PERIOD_M5 = 5,
|
||||
PERIOD_M6 = 6,
|
||||
PERIOD_M10 = 10,
|
||||
PERIOD_M12 = 12,
|
||||
PERIOD_M15 = 15,
|
||||
PERIOD_M20 = 20,
|
||||
PERIOD_M30 = 30,
|
||||
PERIOD_H1 = 16385,
|
||||
PERIOD_H2 = 16386,
|
||||
PERIOD_H3 = 16387,
|
||||
PERIOD_H4 = 16388,
|
||||
PERIOD_H6 = 16390,
|
||||
PERIOD_H8 = 16392,
|
||||
PERIOD_H12 = 16396,
|
||||
PERIOD_D1 = 16408,
|
||||
PERIOD_W1 = 32769,
|
||||
PERIOD_MN1 = 49153
|
||||
}
|
||||
|
||||
public enum ENUM_SERIES_INFO_INTEGER
|
||||
{
|
||||
SERIES_BARS_COUNT = 0,
|
||||
SERIES_FIRSTDATE = 1,
|
||||
SERIES_LASTBAR_DATE = 5,
|
||||
SERIES_SERVER_FIRSTDATE = 2,
|
||||
SERIES_TERMINAL_FIRSTDATE = 3,
|
||||
SERIES_SYNCHRONIZED = 4
|
||||
}
|
||||
|
||||
public enum ENUM_SYMBOL_INFO_INTEGER
|
||||
{
|
||||
SYMBOL_SELECT = 0,
|
||||
SYMBOL_SESSION_DEALS = 56,
|
||||
SYMBOL_SESSION_BUY_ORDERS = 60,
|
||||
SYMBOL_SESSION_SELL_ORDERS = 62,
|
||||
SYMBOL_VOLUME = 10,
|
||||
SYMBOL_VOLUMEHIGH = 11,
|
||||
SYMBOL_VOLUMELOW = 12,
|
||||
SYMBOL_TIME = 15,
|
||||
SYMBOL_DIGITS = 17,
|
||||
SYMBOL_SPREAD_FLOAT = 41,
|
||||
SYMBOL_SPREAD = 18,
|
||||
SYMBOL_TICKS_BOOKDEPTH = 25,
|
||||
SYMBOL_TRADE_CALC_MODE = 29,
|
||||
SYMBOL_TRADE_MODE = 30,
|
||||
SYMBOL_START_TIME = 51,
|
||||
SYMBOL_EXPIRATION_TIME = 52,
|
||||
SYMBOL_TRADE_STOPS_LEVEL = 31,
|
||||
SYMBOL_TRADE_FREEZE_LEVEL = 32,
|
||||
SYMBOL_TRADE_EXEMODE = 33,
|
||||
SYMBOL_SWAP_MODE = 37,
|
||||
SYMBOL_SWAP_ROLLOVER3DAYS = 40,
|
||||
SYMBOL_EXPIRATION_MODE = 49,
|
||||
SYMBOL_FILLING_MODE = 50
|
||||
}
|
||||
|
||||
public enum ENUM_SYMBOL_INFO_DOUBLE
|
||||
{
|
||||
SYMBOL_BID = 1,
|
||||
SYMBOL_BIDHIGH = 2,
|
||||
SYMBOL_BIDLOW = 3,
|
||||
SYMBOL_ASK = 4,
|
||||
SYMBOL_ASKHIGH = 5,
|
||||
SYMBOL_ASKLOW = 6,
|
||||
SYMBOL_LAST = 7,
|
||||
SYMBOL_LASTHIGH = 8,
|
||||
SYMBOL_LASTLOW = 9,
|
||||
SYMBOL_POINT = 16,
|
||||
SYMBOL_TRADE_TICK_VALUE = 26,
|
||||
SYMBOL_TRADE_TICK_VALUE_PROFIT = 53,
|
||||
SYMBOL_TRADE_TICK_VALUE_LOSS = 54,
|
||||
SYMBOL_TRADE_TICK_SIZE = 27,
|
||||
SYMBOL_TRADE_CONTRACT_SIZE = 28,
|
||||
SYMBOL_VOLUME_MIN = 34,
|
||||
SYMBOL_VOLUME_MAX = 35,
|
||||
SYMBOL_VOLUME_STEP = 36,
|
||||
SYMBOL_VOLUME_LIMIT = 55,
|
||||
SYMBOL_SWAP_LONG = 38,
|
||||
SYMBOL_SWAP_SHORT = 39,
|
||||
SYMBOL_MARGIN_INITIAL = 42,
|
||||
SYMBOL_MARGIN_MAINTENANCE = 43,
|
||||
SYMBOL_MARGIN_LONG = 44,
|
||||
SYMBOL_MARGIN_SHORT = 45,
|
||||
SYMBOL_MARGIN_LIMIT = 46,
|
||||
SYMBOL_MARGIN_STOP = 47,
|
||||
SYMBOL_MARGIN_STOPLIMIT = 48,
|
||||
SYMBOL_SESSION_VOLUME = 57,
|
||||
SYMBOL_SESSION_TURNOVER = 58,
|
||||
SYMBOL_SESSION_INTEREST = 59,
|
||||
SYMBOL_SESSION_BUY_ORDERS_VOLUME = 61,
|
||||
SYMBOL_SESSION_SELL_ORDERS_VOLUME = 63,
|
||||
SYMBOL_SESSION_OPEN = 64,
|
||||
SYMBOL_SESSION_CLOSE = 65,
|
||||
SYMBOL_SESSION_AW = 66,
|
||||
SYMBOL_SESSION_PRICE_SETTLEMENT = 67,
|
||||
SYMBOL_SESSION_PRICE_LIMIT_MIN = 68,
|
||||
SYMBOL_SESSION_PRICE_LIMIT_MAX = 69
|
||||
}
|
||||
|
||||
public enum ENUM_SYMBOL_INFO_STRING
|
||||
{
|
||||
SYMBOL_CURRENCY_BASE = 22,
|
||||
SYMBOL_CURRENCY_PROFIT = 23,
|
||||
SYMBOL_CURRENCY_MARGIN = 24,
|
||||
SYMBOL_BANK = 19,
|
||||
SYMBOL_DESCRIPTION = 20,
|
||||
SYMBOL_ISIN = 70,
|
||||
SYMBOL_PATH = 21
|
||||
}
|
||||
|
||||
public enum ENUM_DAY_OF_WEEK
|
||||
{
|
||||
SUNDAY = 0,
|
||||
MONDAY = 1,
|
||||
TUESDAY = 2,
|
||||
WEDNESDAY = 3,
|
||||
THURSDAY = 4,
|
||||
FRIDAY = 5,
|
||||
SATURDAY = 6
|
||||
}
|
||||
|
||||
public enum ENUM_BOOK_TYPE
|
||||
{
|
||||
BOOK_TYPE_SELL = 1,
|
||||
BOOK_TYPE_BUY = 2,
|
||||
BOOK_TYPE_SELL_MARKET = 3,
|
||||
BOOK_TYPE_BUY_MARKET = 4
|
||||
}
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5Quote
|
||||
{
|
||||
public string Instrument { get; private set; }
|
||||
public double Bid { get; private set; }
|
||||
public double Ask { get; private set; }
|
||||
|
||||
public Mt5Quote(string instrument, double bid, double ask)
|
||||
{
|
||||
Instrument = instrument;
|
||||
Bid = bid;
|
||||
Ask = ask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
public class Mt5QuoteEventArgs: EventArgs
|
||||
{
|
||||
public Mt5Quote Quote { get; private set; }
|
||||
|
||||
public Mt5QuoteEventArgs(Mt5Quote quote)
|
||||
{
|
||||
Quote = quote;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
class Mt5TimeConverter
|
||||
{
|
||||
public static DateTime ConvertFromMtTime(int time)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static DateTime ConvertFromMtTime(long time)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
||||
}
|
||||
|
||||
public static int ConvertToMtTime(DateTime time)
|
||||
{
|
||||
int result = 0;
|
||||
if (time != DateTime.MinValue)
|
||||
{
|
||||
DateTime tmpTime = new DateTime(1970, 1, 1);
|
||||
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{AC8B5010-DA75-477E-9CA5-547C649E12D8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MtApi5</RootNamespace>
|
||||
<AssemblyName>MtApi5</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MqlBookInfo.cs" />
|
||||
<Compile Include="MqlRates.cs" />
|
||||
<Compile Include="MqlTick.cs" />
|
||||
<Compile Include="MqlTradeCheckResult.cs" />
|
||||
<Compile Include="Mt5TimeConverter.cs" />
|
||||
<Compile Include="Mt5Enums.cs" />
|
||||
<Compile Include="Mt5ConnectionEventArgs.cs" />
|
||||
<Compile Include="Mt5ConnectionState.cs" />
|
||||
<Compile Include="ExtensionMethods.cs" />
|
||||
<Compile Include="MqlTradeRequest.cs" />
|
||||
<Compile Include="MqlTradeResult.cs" />
|
||||
<Compile Include="Mt5QuoteEventArgs.cs" />
|
||||
<Compile Include="MtApi5Client.cs" />
|
||||
<Compile Include="MtCommandType.cs" />
|
||||
<Compile Include="MtConverters.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Mt5Quote.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
|
||||
<Project>{DE76D5C7-B99C-4467-8408-78173BDD84E0}</Project>
|
||||
<Name>MTApiService</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
Executable
+1504
File diff suppressed because it is too large
Load Diff
Executable
+104
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
enum Mt5CommandType
|
||||
{
|
||||
//NoCommand = 0
|
||||
|
||||
//trade operations
|
||||
OrderSend = 1,
|
||||
OrderCalcMargin = 2,
|
||||
OrderCalcProfit = 3,
|
||||
OrderCheck = 4,
|
||||
//OrderSendAsync = 5,
|
||||
PositionsTotal = 6,
|
||||
PositionGetSymbol = 7,
|
||||
PositionSelect = 8,
|
||||
PositionGetDouble = 9,
|
||||
PositionGetInteger = 10,
|
||||
PositionGetString = 11,
|
||||
OrdersTotal = 12,
|
||||
OrderGetTicket = 13,
|
||||
OrderSelect = 14,
|
||||
OrderGetDouble = 15,
|
||||
OrderGetInteger = 16,
|
||||
OrderGetString = 17,
|
||||
HistorySelect = 18,
|
||||
HistorySelectByPosition = 19,
|
||||
HistoryOrderSelect = 20,
|
||||
HistoryOrdersTotal = 21,
|
||||
HistoryOrderGetTicket = 22,
|
||||
HistoryOrderGetDouble = 23,
|
||||
HistoryOrderGetInteger = 24,
|
||||
HistoryOrderGetString = 25,
|
||||
HistoryDealSelect = 26,
|
||||
HistoryDealsTotal = 27,
|
||||
HistoryDealGetTicket = 28,
|
||||
HistoryDealGetDouble = 29,
|
||||
HistoryDealGetInteger = 30,
|
||||
HistoryDealGetString = 31,
|
||||
|
||||
//Account Information
|
||||
AccountInfoDouble = 32,
|
||||
AccountInfoInteger = 33,
|
||||
AccountInfoString = 34,
|
||||
|
||||
//Access to Timeseries and Indicator Data
|
||||
SeriesInfoInteger = 35,
|
||||
Bars = 36,
|
||||
Bars2 = 1036,
|
||||
BarsCalculated = 37,
|
||||
// IndicatorCreate = 38,
|
||||
// IndicatorParameters = 38,
|
||||
// IndicatorRelease = 39,
|
||||
CopyBuffer = 40,
|
||||
CopyBuffer1 = 1040,
|
||||
CopyBuffer2 = 1140,
|
||||
CopyRates = 41,
|
||||
CopyRates1 = 1041,
|
||||
CopyRates2 = 1141,
|
||||
CopyTime = 42,
|
||||
CopyTime1 = 1042,
|
||||
CopyTime2 = 1142,
|
||||
CopyOpen = 43,
|
||||
CopyOpen1 = 1043,
|
||||
CopyOpen2 = 1143,
|
||||
CopyHigh = 44,
|
||||
CopyHigh1 = 1044,
|
||||
CopyHigh2 = 1144,
|
||||
CopyLow = 45,
|
||||
CopyLow1 = 1045,
|
||||
CopyLow2 = 1145,
|
||||
CopyClose = 46,
|
||||
CopyClose1 = 1046,
|
||||
CopyClose2 = 1146,
|
||||
CopyTickVolume = 47,
|
||||
CopyTickVolume1 = 1047,
|
||||
CopyTickVolume2 = 1147,
|
||||
CopyRealVolume = 48,
|
||||
CopyRealVolume1 = 1048,
|
||||
CopyRealVolume2 = 1148,
|
||||
CopySpread = 49,
|
||||
CopySpread1 = 1049,
|
||||
CopySpread2 = 1149,
|
||||
|
||||
//Market Information
|
||||
SymbolsTotal = 50,
|
||||
SymbolName = 51,
|
||||
SymbolSelect = 52,
|
||||
SymbolIsSynchronized = 53,
|
||||
SymbolInfoDouble = 54,
|
||||
SymbolInfoInteger = 55,
|
||||
SymbolInfoString = 56,
|
||||
SymbolInfoTick = 57,
|
||||
SymbolInfoSessionQuote = 58,
|
||||
SymbolInfoSessionTrade = 59,
|
||||
MarketBookAdd = 60,
|
||||
MarketBookRelease = 61,
|
||||
MarketBookGet = 62
|
||||
}
|
||||
}
|
||||
Executable
+160
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MTApiService;
|
||||
using System.Collections;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
static class MtConverters
|
||||
{
|
||||
#region Values Converters
|
||||
public static Mt5Quote Parse(this MtQuote quote)
|
||||
{
|
||||
return (quote != null) ? new Mt5Quote(quote.Instrument, quote.Bid, quote.Ask) : null;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out MqlTradeResult result)
|
||||
{
|
||||
bool retVal = false;
|
||||
result = null;
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
string[] values = inputString.Split(separator);
|
||||
if (values.Length == 10)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
uint retcode = uint.Parse(values[1]);
|
||||
ulong deal = ulong.Parse(values[2]);
|
||||
ulong order = ulong.Parse(values[3]);
|
||||
double volume = double.Parse(values[4]);
|
||||
double price = double.Parse(values[5]);
|
||||
double bid = double.Parse(values[6]);
|
||||
double ask = double.Parse(values[7]);
|
||||
string comment = values[8];
|
||||
uint request_id = uint.Parse(values[9]);
|
||||
|
||||
result = new MqlTradeResult(retcode, deal, order, volume, price, bid, ask, comment, request_id);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out MqlTradeCheckResult result)
|
||||
{
|
||||
bool retVal = false;
|
||||
result = null;
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
string[] values = inputString.Split(separator);
|
||||
if (values.Length == 10)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
uint retcode = uint.Parse(values[1]);
|
||||
double balance = double.Parse(values[2]);
|
||||
double equity = double.Parse(values[3]);
|
||||
double profit = double.Parse(values[4]);
|
||||
double margin = double.Parse(values[5]);
|
||||
double margin_free = double.Parse(values[6]);
|
||||
double margin_level = double.Parse(values[7]);
|
||||
string comment = values[8];
|
||||
|
||||
result = new MqlTradeCheckResult(retcode, balance, equity, profit, margin, margin_free, margin_level, comment);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out double result)
|
||||
{
|
||||
bool retVal = false;
|
||||
result = 0;
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
string[] values = inputString.Split(separator);
|
||||
if (values.Length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
result = double.Parse(values[1]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static bool ParseResult(this string inputString, char separator, out DateTime from, out DateTime to)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
from = new DateTime();
|
||||
to = new DateTime();
|
||||
|
||||
if (string.IsNullOrEmpty(inputString) == false)
|
||||
{
|
||||
string[] values = inputString.Split(separator);
|
||||
if (values.Length == 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
retVal = int.Parse(values[0]) != 0;
|
||||
|
||||
int iFrom = int.Parse(values[1]);
|
||||
from = Mt5TimeConverter.ConvertFromMtTime(iFrom);
|
||||
|
||||
int iTo= int.Parse(values[2]);
|
||||
to = Mt5TimeConverter.ConvertFromMtTime(iTo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static ArrayList ToArrayList(this MqlTradeRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
int exp = Mt5TimeConverter.ConvertToMtTime(request.Expiration);
|
||||
|
||||
return new ArrayList { (int)request.Action, request.Magic, request.Order, request.Symbol, request.Volume
|
||||
, request.Price, request.Stoplimit, request.Sl, request.Tp, request.Deviation, (int)request.Type
|
||||
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment };
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MtApi5")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MtApi5")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f3256daf-a5c0-422d-9d79-f7156cccb910")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.5.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.5.0")]
|
||||
Reference in New Issue
Block a user