Loading…

Equity At Price Curve Exporter

A grid, a hedge, or several tickets stacked on one symbol each have an obvious P&L at the current price, but the shape of that P&L across a range of prices is not obvious from the ticket list - not without doing the arithmetic for every price level by hand. That shape matters: it is where a grid's next danger zone sits, or where a locked position's true directional risk reappears. This script sweeps a chosen symbol's price across a range and, at each sample point, recomputes what the account's equity would be if price were there right now, holding every other open symbol's floating P&L at its current value. The result is written to a CSV file with one row per sample, ready to chart in a spreadsheet. A second, optional column simulates every resting pending order on the swept symbol as filled once the sampled price has passed its trigger level, so the payoff shape can also be seen the moment a grid or ladder starts firing - not just the shape of what is already open. Notes and limitations - Money-per-point-per-lot is treated as constant across the swept range. Accurate for any realistic sweep width; a very wide range on an instrument whose tick value changes materially with price would drift from this assumption. - The pending-simulation column checks each sampled price level independently against the pending's trigger price - it does not model the path price actually travels to reach that level, so a gap that skips straight past a trigger without ever trading at it is not distinguished from a trigger reached in the normal way. - Other open symbols' floating P&L is held constant at its value when the script runs, not re-swept. This script answers "what if this one symbol moves", not "what if the whole market moves together". - Only market positions and, optionally, pending orders on the swept symbol feed the curve. Positions on other symbols only contribute their current static floating P&L to the baseline.

Script · MT5 · v1.0 · Free

About Equity At Price Curve Exporter

Equity At Price Curve Exporter is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Symbol, Low price and High price. MQL source code included.

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

Settings

SettingDefaultWhat it does
SymbolSymbol to sweep ("" = this chart's symbol)
Low price0.0Low end of the sweep (0 = auto, current price - InpRangePips)
High price0.0High end of the sweep (0 = auto, current price + InpRangePips)
Range pips500Auto-range half-width in pips, used only when Low/High are both 0
Steps41Number of sample points across the range (minimum 3)
Simulate pendingtrueAdd a second column simulating this symbol's pendings as triggered
Magic filter-1Magic number filter for positions/pendings on this symbol (-1 = every magic)
File nameEquityAtPriceCurve.csvOutput file, written into MQL5\Files\

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Grid · Hedging · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria