Loading…

Drag The Line Position Sizer

Working out a lot size for a discretionary stop usually means typing the stop distance into a spreadsheet or a separate calculator, then typing the result back into the order ticket. This EA collapses that into one drag: it draws a single horizontal line labelled as the stop, and every time it is dragged the chart comment updates with the position size a risk-percent input would produce if that line's price were the stop-loss. The sizing math is the part worth reading before attaching it. A common shortcut multiplies the stop distance in points by an assumed per-point cost, which only holds on a USD account trading a USD-quoted pair. This EA instead reads MODE_TICKVALUE and MODE_TICKSIZE for the symbol and derives the actual money cost of the stop distance from them - correct on JPY crosses, metals, indices, and any account currency, not just the textbook case. The recompute is wired to CHARTEVENT_OBJECT_DRAG rather than OnTick. There is nothing to evaluate between drags - the line does not move on its own - so polling every tick would just repeat the same calculation for no reason. This EA never calls OrderSend. It is a calculator that happens to live on a chart, not a trading system - read that as a promise, not a limitation to work around. Notes and limitations - This EA places no orders and modifies no positions. It exists only to display a calculated lot size in the chart comment. - The stop line is created once and then left alone on every subsequent init, so a recompile, timeframe change or parameter change does not throw away a level you have already positioned. Removing the EA from the chart removes the line; a recompile or symbol change does not. - Distance is measured to the nearer side of the current Bid/Ask spread, because the line itself does not encode a trade direction - the trader reads the price and decides whether it implies a long or a short stop. - If the computed raw lot size is below the broker's minimum, the size shown is floored up to the minimum and the comment says so explicitly - that means the actual risk at that stop exceeds the target percentage. - Depends on the broker reporting the tick value and tick size correctly (MODE_TICKVALUE/MODE_TICKSIZE on MQL4, SYMBOL_TRADE_TICK_VALUE/ SYMBOL_TRADE_TICK_SIZE on MQL5). If either is zero or unavailable, the comment says so instead of showing a nonsensical size.

Expert advisor · MT5 · v1.0 · Free

About Drag The Line Position Sizer

Drag The Line Position Sizer is a script for MetaTrader 5. It has 3 settings, such as Risk percent, Line color and Line width. MQL source code included.

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

Settings

SettingDefaultWhat it does
Risk percent1.0Risk % of balance per trade
Line colorclrOrangeRedStop line colour
Line width2Stop line width

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: Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria