Skip to content

Commit a5d61cf

Browse files
authored
Add files via upload
1 parent 8c6d2d8 commit a5d61cf

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

MT5socketAPI/Position.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class Position
3030
public long REASON { get; set; }
3131
public double PRICE_CURRENT { get; set; }
3232
public string EXTERNAL_ID { get; set; }
33+
public double CHANGE { get; set; }
3334
public override string ToString()
3435
{
3536
return JsonConvert.SerializeObject(this);

MT5socketAPI/Terminal.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using System.Net.Sockets;
44
using System.Text;
5+
using System.Globalization;
56

67
namespace MTsocketAPI.MT5
78
{
@@ -313,7 +314,7 @@ public bool Connect(string host = "127.0.0.1", int cmd_port = 77, int data_port
313314
//{
314315
// Version = res["NUMBER"].ToString();
315316

316-
// if (Convert.ToDouble(Version) < 5.21)
317+
// if (Convert.ToDouble(Version,CultureInfo.InvariantCulture) < 5.21)
317318
// {
318319
// throw new Exception("This API version needs at least MTsocketAPI 5.21 version");
319320
// }
@@ -760,7 +761,7 @@ public List<Rates> PriceHistory(string Symbol, TimeFrame tf, DateTime FromDate,
760761
/// <param name="Comment">Order Comment (optional)</param>
761762
/// <param name="MagicNr">Magic Number (optional)</param>
762763
/// <param name="Expiration">Order Expiration Date. Only for limit or stop orders (optional)</param>
763-
public TradeResult SendOrder(string Symbol, double Volume, OrderType Type, double Price = 0, double SL = 0, double TP = 0, double Slippage = 0, string Comment = "", int MagicNr = 0, string Expiration = "1970/01/01 00:00")
764+
public TradeResult SendOrder(string Symbol, double Volume, OrderType Type, double Price = 0, double SL = 0, double TP = 0, double Slippage = 0, string Comment = "", int MagicNr = 0, string Expiration = "1970/01/01 00:00", bool Async = false)
764765
{
765766
try
766767
{
@@ -776,8 +777,9 @@ public TradeResult SendOrder(string Symbol, double Volume, OrderType Type, doubl
776777
if (Comment != "") json_cmd["COMMENT"] = Comment;
777778
if (MagicNr > 0) json_cmd["MAGICNR"] = MagicNr;
778779
if (Expiration != "1970/01/01 00:00") json_cmd["EXPIRATION"] = Expiration;
780+
if (Async != false) json_cmd["ASYNC"] = true;
779781

780-
JObject res = SendCommand(json_cmd);
782+
JObject res = SendCommand(json_cmd);
781783

782784
if (res["ERROR_ID"].ToString() == "0")
783785
{
@@ -800,7 +802,7 @@ public TradeResult SendOrder(string Symbol, double Volume, OrderType Type, doubl
800802
/// <param name="Ticket">Ticket Number</param>
801803
/// <param name="SL">Stop loss price (optional)</param>
802804
/// <param name="TP">Take profit price (optional)</param>
803-
public TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0)
805+
public TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0, bool Async = false)
804806
{
805807
try
806808
{
@@ -809,8 +811,9 @@ public TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0)
809811
json_cmd["TICKET"] = Ticket;
810812
if (SL > 0) json_cmd["SL"] = SL;
811813
if (TP != 0) json_cmd["TP"] = TP;
814+
if (Async != false) json_cmd["ASYNC"] = true;
812815

813-
JObject res = SendCommand(json_cmd);
816+
JObject res = SendCommand(json_cmd);
814817

815818
if (res["ERROR_ID"].ToString() == "0")
816819
{
@@ -835,7 +838,7 @@ public TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0)
835838
/// <param name="Volume">Volume size (optional)</param>
836839
/// <param name="Price">Desired Price (optional)</param>
837840
/// <param name="Slippage">Max lippage (optional)</param>
838-
public TradeResult OrderClose(long Ticket, double Volume = 0, double Price = 0, double Slippage = 0)
841+
public TradeResult OrderClose(long Ticket, double Volume = 0, double Price = 0, double Slippage = 0, bool Async = false)
839842
{
840843
try
841844
{
@@ -845,8 +848,9 @@ public TradeResult OrderClose(long Ticket, double Volume = 0, double Price = 0,
845848
if (Volume > 0) json_cmd["VOLUME"] = Volume;
846849
if (Price != 0) json_cmd["PRICE"] = Price;
847850
if (Slippage != 0) json_cmd["SLIPPAGE"] = Slippage;
851+
if (Async != false) json_cmd["ASYNC"] = true;
848852

849-
JObject res = SendCommand(json_cmd);
853+
JObject res = SendCommand(json_cmd);
850854

851855
if (res["ERROR_ID"].ToString() == "0")
852856
{
@@ -1267,16 +1271,16 @@ public interface ITerminal
12671271
List<OrderDeal> GetTradeHistoryOrdersDeals(DateTime FromDate, DateTime ToDate);
12681272
List<Position> GetTradeHistoryPositions(DateTime FromDate, DateTime ToDate);
12691273
List<double> MA_Indicator(string Symbol, TimeFrame tf, int MA_Period, int MA_Shift, MA_Method MA_Method, Applied_Price Applied_Price, int Shift, int Num = 1);
1270-
TradeResult OrderClose(long Ticket, double Volume = 0, double Price = 0, double Slippage = 0);
1271-
TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0);
1274+
TradeResult OrderClose(long Ticket, double Volume = 0, double Price = 0, double Slippage = 0, bool Async = false);
1275+
TradeResult OrderModify(long Ticket, double SL = 0, double TP = 0, bool Async = false);
12721276
List<Rates> PriceHistory(string Symbol, TimeFrame tf, DateTime FromDate, DateTime ToDate);
12731277
JObject SendCommand(JObject cmd);
12741278
Task<JObject> SendCommandAsync(string host, int port, JObject cmd);
1275-
TradeResult SendOrder(string Symbol, double Volume, OrderType Type, double Price = 0, double SL = 0, double TP = 0, double Slippage = 0, string Comment = "", int MagicNr = 0, string Expiration = "1970/01/01 00:00");
1279+
TradeResult SendOrder(string Symbol, double Volume, OrderType Type, double Price = 0, double SL = 0, double TP = 0, double Slippage = 0, string Comment = "", int MagicNr = 0, string Expiration = "1970/01/01 00:00", bool Async = false);
12761280
bool TrackOHLC(List<OHLC_Req> ohlc_request);
12771281
bool TrackOrderEvent();
12781282
bool TrackOrderEvent(bool enable);
12791283
bool TrackPrices(List<Asset> symbols);
12801284
bool TrackPrices(List<string> symbols);
12811285
}
1282-
}
1286+
}

0 commit comments

Comments
 (0)