Loading…

Position Size Calculator Panel

Position sizing by risk percentage is simple in principle and easy to get wrong in practice, because the conversion from a price distance to a lot size depends on the symbol's tick value and tick size, not a flat number a trader can memorise across FX pairs, metals and indices. This panel removes the manual step: drag the red dashed line to the price where the stop belongs - based on structure, an ATR multiple, whatever the trader's analysis says - and the panel immediately shows the lot size that risks the configured percentage of the account, normalised to the broker's lot step and clamped to the broker's minimum and maximum. Lot size is solved from MODE_TICKVALUE divided by MODE_TICKSIZE, which gives the money value of one price unit for a single lot on the current symbol - correct on a 3-digit JPY pair, a 5-digit majors pair, gold or an index CFD alike, because it reads the broker's actual contract specification rather than assuming a fixed 100,000-unit lot. The raw lot size is then floored to the broker's MODE_LOTSTEP with a small epsilon guard, because floating point division of a lot step (0.1 / 0.01 is not exactly 10 in binary) can otherwise silently floor a position to half the size it should be - a documented trap that this indicator specifically guards against. Two stop modes are available. Manual mode gives full control: drag the line anywhere and the panel reacts immediately, including mid-drag via CHARTEVENT_OBJECT_DRAG so there is no need to release and wait for the next tick. ATR mode instead sets the stop automatically at a configurable ATR multiple below the current price, useful as a quick volatility-based starting point without touching the line by hand. Notes and limitations - This is a sizing calculator, not an order-placing tool - it does not send any trade. Enter the lot size it shows into the order ticket manually. - ATR mode always sizes a long-style stop below the current price. For a short setup, switch to manual mode and drag the line above price instead. - The lot size shown is already normalised and clamped, so the "actual risk" figure can differ slightly from the requested risk percentage whenever the raw calculation does not land exactly on a lot step - this is expected and unavoidable with any fixed lot step broker. - If the stop distance is zero (the line sits exactly on price), the lot size cannot be computed and shows as zero rather than dividing by zero. - The stop line and panel are chart objects, prefixed and removed cleanly in OnDeinit.

Indicator · MT5 · v1.0 · Free

About Position Size Calculator Panel

Position Size Calculator Panel is an indicator for MetaTrader 5 based on ATR. It has 9 settings, such as Risk percent, Risk basis and Stop mode. MQL source code included.

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

Settings

SettingDefaultWhat it does
Risk percent1.0Risk per trade, percent of the basis below
Risk basisRISK_BASIS_BALANCEWhat the percent is applied to
Stop modeSTOP_MODE_MANUALHow the stop distance is set
Atr period14ATR period, used only in ATR stop mode
Atr multiple2.0ATR multiple, used only in ATR stop mode
CornerCORNER_RIGHT_UPPERInfo panel corner
X distance10Info panel horizontal offset, pixels
Y distance20Info 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: Risk & Lot Size · ATR · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria