Skip to content

Commit

Permalink
Issue #14: Updated test application for using function PositionOpen w…
Browse files Browse the repository at this point in the history
…ith MqlTradeResult
  • Loading branch information
vdemydiuk committed Sep 29, 2017
1 parent cd24891 commit b838084
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 6 additions & 1 deletion MtApi5/MqlTradeResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public MqlTradeResult(uint retcode, ulong deal, ulong order, double volume, doub
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
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch

public override string ToString()
{
return $"Retcode={Retcode}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Comment={Comment}; Request_id={Request_id}";
}
}
}
11 changes: 6 additions & 5 deletions TestClients/MtApi5TestClient/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,14 @@ private async void ExecutePositionOpen(object obj)
const string symbol = "EURUSD";
const ENUM_ORDER_TYPE orderType = ENUM_ORDER_TYPE.ORDER_TYPE_BUY;
const double volume = 0.1;
const double price = 1.013;
const double sl = 1.00;
const double tp = 1.020;
const double price = 1.18129;
const double sl = 1.1811;
const double tp = 1.1814;
const string comment = "Test PositionOpen";
MqlTradeResult tradeResult = null;

var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment));
AddLog($"PositionOpen: symbol EURUSD result = {retVal}");
var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment, out tradeResult));
AddLog($"PositionOpen: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
}

private async void ExecutePrint(object obj)
Expand Down

0 comments on commit b838084

Please sign in to comment.