Loading…

Open Position Average Price

When several tickets are open on the same symbol - scaled in, hedged, or just opened at different times - the terminal shows every ticket separately and nothing shows the position as a whole. This indicator scans every open order on the current symbol, splits them into buys and sells, and draws the lot-weighted average entry price for each side as a horizontal line, so the true blended entry is visible at a glance instead of mentally averaging a list of tickets. It also draws a second line most average-price tools skip: breakeven. The raw average entry price is not the price at which a position is actually flat once swap and commission are counted - a position that has paid negative swap for several nights needs price to move further than the raw average before it nets to zero. The breakeven offset is solved from the account-currency swap and commission already on the tickets, converted back to a price distance using MODE_TICKVALUE divided by MODE_TICKSIZE, scaled by the actual summed lot size of that side. Nothing here assumes a fixed contract size, so the maths holds on metals, indices and any mix of lot sizes across the open tickets. The info panel adds the lot-weighted average stop distance and the total money at risk for each side, using the same tick-value-per-lot maths, for tickets that actually have a stop set. Notes and limitations - Only positions on the current chart symbol are counted; positions on other symbols are ignored, matching what the drawn lines can actually mean on this chart. - Pending orders are excluded - only open market positions count toward the averages. - The breakeven line uses swap and commission already recorded at the moment of the refresh; it does not project future swap, so it moves slightly each night as more swap accrues. - Stop distance and risk figures only include positions that currently have a stop loss set; positions without one are counted in the average entry but not in the stop distance panel row. - Refreshes every tick and once a second on a timer, so it stays current even while this symbol is not printing new ticks. On MQL5 this means the per-position commission history lookup also runs on that cadence; with a very large number of simultaneously open positions on one symbol this is more history-lookup work per refresh than the MQL4 version's direct OrderCommission() read, though not enough to matter at normal position counts.

Indicator · MT5 · v1.0 · Free

About Open Position Average Price

Open Position Average Price is an indicator for MetaTrader 5. It has 7 settings, such as Buy color, Sell color and Break even color. MQL source code included.

Files in the download: OpenPositionAveragePrice.ex5, OpenPositionAveragePrice.mq5, OpenPositionAveragePrice.txt.

Settings

SettingDefaultWhat it does
Buy colorclrDodgerBlueBuy average entry line colour
Sell colorclrCrimsonSell average entry line colour
Break even colorclrGoldenrodBreakeven line colour
CornerCORNER_LEFT_LOWERInfo panel corner
X distance10Info panel horizontal offset, pixels
Y distance10Info panel vertical offset, pixels
Font size9Info panel font size

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Hedging · Trailing Stop & Break-even · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria