MarketPosition at Broker

From MultiCharts
Jump to navigation Jump to search

Returns a numerical value, indicating the number of contracts and the type of position at the broker for the symbol. A positive value indicates a long position and a negative value indicates a short position.

A zero ('0') is returned when the current position is flat, or if Automated Trading is not turned on.

Usage

MarketPosition_at_Broker

Notes

  • This function can only be used in signals and functions. Use the i_MarketPosition_at_Broker to access it in indicators.
  • This function differs from the MarketPosition keyword in that it cannot take an argument to reference past values. By saving the value of MarketPosition_at_Broker to a Numeric Variable, it's possible to reference the position at the broker for previous bars or ticks.
  • MarketPosition_at_Broker works with all brokers, though there are some peculiarities with Trading Technologies ([1]):
The Trading Technologies API doesn't provide information about positions opened the day before, in which case MultiCharts uses the average of all complete long (short) trades for the day to calculate the EntryPrice.

Important

If Automated Trading was manually turned off by the user, the value returned by the keyword stops changing, and may remain unequal to '0'.

Example

MarketPosition_at_Broker
  • Will will return '17' if the current position at the broker for the strategy is 17 contracts long.
  • Will return '-132' if the current position at the broker for the strategy is 132 contracts short.
  • Will return '0' if the current position at the broker for the strategy is flat.
  • Will return '0' if the Automated Trading Mode is not turned on.