Trade operations (Positions.Positions.Check)

Swing trading, Technical indicators, Technical trading, Trading algorithms, Trading education, Trading psychology, Trading platforms, Trading signals software, Trading tip, Trading tutorials.

Position - an uncompleted trading operation (unfinished deal). When changing the quotation of a financial instrument, the position keeps a record of the client’s funds (for write-off and crediting). 

This section describes properties and methods for working with positions

It sends a request to the server to check if there are enough funds to open a position

int Positions.Check(symbolName, positionType, volume, closePrice, out margin, out profit)

Input parameters

Parameter Type Description
symbolName string Symbol name
positionType PositionType Buy or Sell
volume double Position volume in lots
closePrice double Position closing price in quoted currency
margin оut double In the parameter, you can set a variable in which the calculated amount of collateral in the account currency will be recorded
profit оut double In the parameter, you can set a variable in which the calculated amount of profit in the account currency will be recorded

 

0 Fund sufficiency check was passed successfully
Error code If an error occurs, it returns the server error code

If the name of a variable is passed to the out parameter Margin, then the amount of funds required to ensure open positions on the account will be recorded to this variable

If the name of a variable is passed to the out parameter Profit, then the amount of the calculated profit will be recorded to this variable

Example:

string symbolName = "EURUSD";
double volume = 0.1;
double bidprice= Symbols.Find(symbolName).Quote.Bid;
double margin;
double profit;
int result;
result = Positions.Check(symbolName, PositionType.Buy, volume, bidprice, out margin, out profit);
if (result == 0) {
 line = " Positions.Check(" + symbolName + ", PositionType.Buy, " + volume.ToString() + ", " + bidprice.ToString() 
 + ", out margin, out profit):";
 
 line = line + " result: " + result.ToString() + ", margin: " + margin.ToString() + ", profit: " + profit.ToString(); 
 using (StreamWriter sw = new StreamWriter(mOnStartLog, true))
 sw.WriteLine(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss:fff") + line + Environment.NewLine);
}