Skip to content
All library documents

Calculating a Hedge Account’s Net Position Average Price

Article MQL5 code base

Summary

This article describes an MQL5 chart indicator intended to estimate the average price of open positions for a selected symbol and Magic Number. It scans open positions, separates buys from sells, and totals each side’s volume and price-weighted cost. The indicator then determines the net direction and displays a corresponding average-price line on the chart.

The description outlines the calculation and the indicator workflow: initialize a display buffer, update it during calculation, and configure the identifier used to select trades. It gives usage guidance for compiling and attaching the indicator in MetaTrader 5, but supplies no performance tests or worked numerical example. The method is a monitoring aid for hedged positions, not a trading signal. Its average-price convention and handling of offsetting long and short lots should be checked against the trader’s intended accounting method, since the explanation does not fully specify those details.

Key ideas

  • The indicator filters open positions by symbol and Magic Number.
  • It calculates separate volume-weighted prices for buy and sell positions.
  • It identifies the net position direction and plots a corresponding average-price line.
  • The article explains setup at a high level but gives no test results or numerical example.
  • The net average-price convention should be verified for the account’s intended position accounting.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.