Broker API HubMenu

MQL5 PositionGetString()

functionPositionGetString()MQL5Positions

Returns one text property of an open position. It reads the position last selected with PositionGetSymbol() or PositionSelect().

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Independent and unofficialmql5.comchecked

This is an MQL5 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 5 terminal, in a program written in MQL5.

Signature

The 2 forms of the call on the vendor's page, with the vendor's comments taken out.

string PositionGetString(
  ENUM_POSITION_PROPERTY_STRING property_id
)
bool PositionGetString(
  ENUM_POSITION_PROPERTY_STRING property_id,
  string& string_var
)

Arguments

NameTypeDescription
property_idrequiredENUM_POSITION_PROPERTY_STRINGWhich property to return, as a value of the ENUM_POSITION_PROPERTY_STRING enumeration.
string_varrequiredstring&Only in the second form: the string variable that receives the value.

Return value

Type
string, or bool in the second form
What comes back
The page gives two forms: one returns the value itself, the other returns true or false and writes the value into a variable passed by reference. The first form returns an empty string when it fails.

Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.

void OnStart()
  {
   if(PositionSelect(_Symbol))
      Print(PositionGetString(POSITION_SYMBOL)," ",PositionGetString(POSITION_COMMENT));
  }