The Position Sizer is a trade management tool for MetaTrader 4 and 5 that calculates the appropriate lot size based on account balance and risk tolerance.
Position Sizer allows traders to define risk as a percentage or fixed monetary amount, adjusting the position size dynamically as stop-loss and take-profit lines are moved on the chart. The EA supports ATR-based levels, commission adjustments, and margin requirement calculations. While it includes trade execution buttons, it functions primarily as a calculator and risk management panel rather than an autonomous trading robot.
Read from Position Sizer.mq4. Defaults are the author's; change them in the EA's Inputs tab.
Name
Type
Default
Description
ShowLineLabels
bool
true
ShowLineLabels: Show point distance for TP/SL near lines?
ShowAdditionalSLLabel
bool
false
ShowAdditionalSLLabel: Show SL $/% label?
ShowAdditionalTPLabel
bool
false
ShowAdditionalTPLabel: Show TP $/% + R/R label?
DrawTextAsBackground
bool
false
DrawTextAsBackground: Draw label objects as background?
PanelOnTopOfChart
bool
true
PanelOnTopOfChart: Draw chart as background?
HideAccSize
bool
false
HideAccSize: Hide account size?
ShowPointValue
bool
false
ShowPointValue: Show point value?
ShowMaxPSButton
bool
false
ShowMaxPSButton: Show Max Position Size button?
StartPanelMinimized
bool
false
StartPanelMinimized: Start the panel minimized?
ShowATROptions
bool
false
ShowATROptions: If true, SL and TP can be set via ATR.
sl_label_font_color
color
clrLime
SL Label Color
tp_label_font_color
color
clrYellow
TP Label Font Color
Show all 40 inputs
Name
Type
Default
Description
font_size
uint
13
Labels Font Size
font_face
string
Courier
Labels Font Face
entry_line_color
color
clrBlue
Entry Line Color
stoploss_line_color
color
clrLime
Stop-Loss Line Color
takeprofit_line_color
color
clrYellow
Take-Profit Line Color
entry_line_style
ENUM_LINE_STYLE
STYLE_SOLID
Entry Line Style
stoploss_line_style
ENUM_LINE_STYLE
STYLE_SOLID
Stop-Loss Line Style
takeprofit_line_style
ENUM_LINE_STYLE
STYLE_SOLID
Take-Profit Line Style
entry_line_width
uint
1
Entry Line Width
stoploss_line_width
uint
1
Stop-Loss Line Width
takeprofit_line_width
uint
1
Take-Profit Line Width
DefaultTradeDirection
TRADE_DIRECTION
Long
TradeDirection: Default trade direction.
DefaultSL
int
0
SL: Default stop-loss value, in broker's points.
DefaultTP
int
0
TP: Default take-profit value, in broker's points.
DefaultEntryType
ENTRY_TYPE
Instant
EntryType: Instant or Pending.
DefaultShowLines
bool
true
ShowLines: Show the lines by default?
DefaultLinesSelected
bool
true
LinesSelected: SL/TP (Entry in Pending) lines selected.
DefaultATRPeriod
int
14
ATRPeriod: Default ATR period.
DefaultATRMultiplierSL
double
0
ATRMultiplierSL: Default ATR multiplier for SL.
DefaultATRMultiplierTP
double
0
ATRMultiplierTP: Default ATR multiplier for TP.
DefaultATRTimeframe
ENUM_TIMEFRAMES
PERIOD_CURRENT
ATRTimeframe: Default timeframe for ATR.
DefaultSpreadAdjustmentSL
bool
false
SpreadAdjustmentSL: Adjust SL by Spread value in ATR mode.
DefaultSpreadAdjustmentTP
bool
false
SpreadAdjustmentTP: Adjust TP by Spread value in ATR mode.
DefaultCommission
double
0
Commission: Default one-way commission per 1 lot.
DefaultAccountButton
ACCOUNT_BUTTON
Balance
AccountButton: Balance/Equity/Balance-CPR
DefaultRisk
double
1
Risk: Initial risk tolerance in percentage points
DefaultMoneyRisk
double
0
MoneyRisk: If > 0, money risk tolerance in currency.
DefaultCountPendingOrders
bool
false
CountPendingOrders: Count pending orders for portfolio risk.
How to Install It
1Download the sourceUse "Download source (.zip)" above, or clone techteam92/positionsize-EA- from GitHub, and unzip it.
2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL4/Experts or MQL5/Experts.
3Copy the filesCopy the .mq4 / .mq5 file into Experts, and any .mqh files into the Include folder the code expects.
4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
5Test before you tradeRun it in the Strategy Tester, then attach it to a demo chart and allow algorithmic trading.
Third-party code. ForexR did not write, test or endorse this EA, and the summary above was generated automatically from its README and code. ForexR lists only repositories with readable source code and never hosts files. Read the code, backtest it and use a demo account first; automated trading can lose money quickly.
This risk management tool for MetaTrader 4 and 5 calculates optimal lot sizes based on user-defined risk parameters, account balance, and currency. It provides a graphical user interface for setting entry, stop loss, and take profit levels visually on the chart. The expert advisor accounts for commissions, swaps, and m
This MetaTrader 5 tool acts as a discretion helper for manual traders to simplify order execution. It automates trade entries by applying calculated risk percentages and setting predefined stop loss and take profit values in pips. The utility features integrated trailing stop functionality, allowing users to define spe
This MetaTrader 5 utility is a comprehensive manual trading panel and risk management suite. It simplifies order execution by calculating lot sizes based on a defined risk percentage of account equity. Users can manage trades via automated break-even points, multi-mode trailing stops including Fractals, Moving Averages
NNFX Backtest C1 is a specialized utility for MetaTrader 4 designed to evaluate external confirmation indicators using the No Nonsense Forex methodology. It enables users to backtest custom indicators by defining signal logic such as two-line crossovers, zero-line crosses, or histogram changes. The system manages risk
This utility for MetaTrader 4 and 5 automates trade execution based on trader-defined chart patterns. Users draw trendlines, horizontal lines, or channels, which the expert advisor monitors to place pending breakout orders. It handles trade entries, stop losses, and take profits according to specific object naming conv
This expert advisor functions as a manual trading assistant for MetaTrader 4 and MetaTrader 5, designed to simplify discretionary order management. It provides a graphical interface on the chart, allowing users to execute trades with pre-defined risk parameters. The tool includes options for percentage-based risk calcu