Bookmark and Share
EA NamePosition Size Calculator
PlatformMT4, MT5
Download MQ4 Format | MQ5 Format
Brief

Position Size Calculator (MetaTrader indicator) tells you how many lots to trade based on:

  • Given entry and stop-loss levels

  • Risk tolerance

  • Account size (balance, equity, or even your savings account)

  • Account currency

  • Price of the quote currency (when different from account currency)

Its main features include:

  • Works with any trading instruments — currency pairs, CFDs, equities, indices, commodities, futures, cryptocurrencies.

  • Calculation inputs and results are displayed inside a graphical panel.

  • The panel can be moved freely across the chart.

  • You can easily close or minimize it.

  • All calculation parameters can be adjusted inside the panel in one or two mouse clicks.

  • Entry, stop-loss, and take-profit lines can be dragged directly on the chart.

  • You can choose to set stop-loss and/or take-profit as distance in points.

  • Alternatively, you can set them as multiples of ATR (Average True Range).

  • If take-profit is given, the calculator shows the potential reward level and the risk-to-reward ratio.

  • Supports pending and instant orders (easy switching).

  • You can even calculate risk based on a given position size.

  • You can see current and potential risk and reward profile.

  • Information about required margin is available in a separate tab.

  • Calculator can show the maximum position size based on available margin.

  • You can enter a custom leverage to calculate position margin based on it.

  • Detailed swaps (rollover interest) information is available in a separate tab.

  • Optional spread display.

  • Optional display of the pip value for the calculated position size.

  • The indicator automatically saves and loads its inputs on timeframe change or platform restart, preserving your configuration efforts.

  • Custom profiles restore panel's location, status, and settings.

  • Completely free and open-source project.

  • Does not require any DLL imports.

  • Can be used together with a trading script (PSC-Trader) to make it easy for traders to open positions based on the calculations.

It is an evolution of the text-based legacy version of the same indicator and is an adaptation of the free online tool by the same name. Position Size Calculator is available for both MT4 and MT5, but the MT5 version looks differently and provides better functionality because the platform itself is more advanced.


Interface

Main tab

The main tab of the panel provides the primary control over the indicator's functions and serves to output the most important calculation results — position size, risk, reward, and risk-to-reward ratio. The following controls and outputs are available:

Position Size Calculator Forex Indicators 1
  1. Indicator's version number.

  2. Spread value in ticks.

  3. Minimization button to fold down the panel.

  4. Close button to remove the indicator from the chart.

  5. Main tab switch — it is currently turned on.

  6. Risk tab switch — click it to see the current and potential risk profile. The Risk tab interface is explained below.

  7. Margin tab switch — click it to see everything related to required and free margin. The Margin tab interface is explained below.

  8. Swaps tab switch — click it to see the details on the swaps for the current trading instrument. The Swaps tab interface is explained below.

  9. Script tab switch — click it to see controls for the PSC-Trader script. The Script tab interface is explained below.

  10. Entry input — grayed out when Instant order is used, can be used enter entry level when Pending order is set.

  11. Stop-loss input.

  12. Take-profit input.

  13. Take-profit button allows quick setting of TP to the level equal to the current SL value.

  14. Take-profit multiplier, if set via input parameters, applies to the current SL value when Take-profit button is pressed.

  15. Order type button to switch between Instant and Pending.

  16. Hide/show lines button to quickly switch the display of the Entry, Take-profit, and Stop-loss lines on the chart.

  17. Commission size per lot (one-way) — set it if your broker charges commission and you want it included into risk size when calculating position size.

  18. Account size in account currency units.

  19. Account size asterisk signals that additional funds are set via input parameters; the funds were added to the account size value.

  20. Account size button switches between balance, equity, and "Balance - CPR"; the latter being account balance less the current portfolio risk as calculated on the Risk tab.

  21. Risk input — you can set your tolerated risk in percentage of the account size. If you set your risk via Risk money input, percentage risk will be calculated based on that input.

  22. Risk money input — you can set your tolerated risk in account currency units. If you set your risk via Risk percentage input, money risk will be calculated based on that input.

  23. Risk (result) — percentage risk calculated based on the actual position size allowed in your broker's platform.

  24. Risk money (result) — money risk calculated based on the actual position size allowed in your broker's platform.

  25. Reward in account currency is based on the position size calculated without taking into account platform's restrictions.

  26. Reward (result) — reward in account currency is based on the actual position size allowed in your broker's platform.

  27. Reward/risk ratio (result) — reward result divided by risk result.

  28. Position size — actual position size calculation output. You can modify it yourself if you want to calculate your risk based on position size.

  29. Pip value per calculated position size.

  30. Reward/risk (input) — input reward divided by input risk.

  31. ATR Period — setting to use with the ATR-based SL/TP.

  32. ATR — current value of ATR with a given period.

  33. SL multiplier — multiplier for ATR-based stop-loss. The ATR value is multiplied by this value to produce the actual stop-loss distance. Set to zero to disable ATR-based stop-loss.

  34. TP multiplier — multiplier for ATR-based take-profit. The ATR value is multiplied by this value to produce the actual take-profit distance. Set to zero to disable ATR-based take-profit.

Risk tab

The risk tab can help you assess current and potential risk and reward profile. Using simple algorithm, the indicator calculates the risk of the currently open positions and pending orders based on their stop-loss levels (or lack thereof). It also assesses the potential reward of already opened positions and the position calculated by the indicator based on take-profit levels. The employed risk analysis method does not account for complex situations involving hedged orders and positions. You can use the Risk Calculator indicator for a deeper portfolio risk analysis. You can control the Risk tab using two checkboxes and see the calculation results in ten output fields:

Position Size Calculator Forex Indicators 2
  1. Count pending orders — if checked, the indicator will also attempt to calculate the risk of pending orders in addition to currently open positions.

  2. Ignore orders without stop-loss/take-profit — if checked, will simply ignore all risk coming from orders and positions without SL/TP value set. Can be useful if you prefer not to set stop-loss/take-profit for some of your trades.

  3. Current portfolio risk (currency) — shows the risk in currency units without the position, which is currently being calculated by this indicator.

  4. Potential portfolio risk (currency) — shows the risk in currency units as if you have already opened a position, which is currently calculated by this indicator.

  5. Current portfolio risk (%) — same as Current portfolio risk (currency) but in percentage to the account size.

  6. Potential portfolio risk (%) — same as Potential portfolio risk (currency) but in percentage to the account size.

  7. Current portfolio reward (currency) — shows the reward in currency units without the position, which is currently being calculated by this indicator.

  8. Potential portfolio reward (currency) — shows the reward in currency units as if you have already opened a position, which is currently calculated by this indicator.

  9. Current portfolio reward (%) — same as Current portfolio reward (currency) but in percentage to the account size.

  10. Potential portfolio reward (%) — same as Potential portfolio reward (currency) but in percentage to the account size.

  11. Current portfolio lots — the total size of the currently open positions in lots.

  12. Potential portfolio lots — the total size in lots of the open positions plus the one, which is currently being calculated by this indicator.

Margin tab

The margin tab provides information about the calculated position's margin, amount of used and available margin after opening the calculated position, and the biggest possible position size considering the current available margin and leverage. The tab has only one input and five output fields:

Position Size Calculator Forex Indicators 3
  1. Position margin shows the margin that will be used for the calculated position. Negative value means that the future used margin will be lower than the current due to lower requirement for margin of the hedged positions.

  2. Future used margin is calculated based on the current used margin and position margin.

  3. Future free margin shows how much free margin you will have left after opening the calculated position.

  4. Default leverage shows the account's actual leverage for your reference.

  5. Maximum position size by margin displays the biggest trade you can take with your currently available free margin and leverage.

  6. Custom leverage input lets you set your own leverage for all the margin calculations done by this indicator.

  7. Symbol leverage shows the actual leverage for the current trading instrument. It is calculated based on required margin and contract size/value. It may be inaccurate in some cases.

Swaps tab

The swaps tab displays details on the overnight interest payments associated with the current trading instrument and calculated position size. It shows swaps type, nominal swaps, daily, yearly, per lot, per calculated position size, and both for long and short positions:

Position Size Calculator Forex Indicators 4
  1. Type shows the type of swaps used by the broker for the current trading instrument. Can be one of several kinds: pips/points, base currency, interest, account currency, margin currency, reopening.

  2. Triple swap shows the day of week when triple swaps are charged/paid (to account for Saturday and Sunday).

  3. Nominal swaps — nominal swaps paid or charged by a broker for long and short positions.

  4. Daily swap per lot — daily swap paid or charged by a broker for long and short positions in account currency per lot.

  5. Daily swap per PS — daily swap paid or charged by a broker for long and short positions in account currency for calculated position size (on the Main tab).

  6. Yearly swap per lot — swap paid or charged by a broker for long and short positions in account currency per lot. Calculated for a period of 360 days.

  7. Yearly swap per PS — swap paid or charged by a broker for long and short positions in account currency for calculated position size (on the Main tab). Calculated for a period of 360 days.

  8. Position size duplicates the display of the position size calculated by the indicator on the Main tab.

Script tab

The script tab serves to provide you with some control over the trading script. You may skip this tab if you are not using PSC-Trader.

Position Size Calculator Forex Indicators 5
  1. Magic number — Magic number that will be assigned to the orders and positions opened using the script.

  2. Order commentary — commentary for orders and positions opened using the script.

  3. Disable trading when lines are hidden — a simple checkbox to prevent script from opening a position when you have chosen to hide the lines via the Main tab.

  4. Max slippage — maximum tolerable slippage value (in broker pips) that will be used in trading functions of the script.

  5. Max spread — the script will not trade if current spread is wider than the value given here.

  6. Max Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes greater than this value.

  7. Min Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes less than this value.

  8. Max position size — if calculated position size exceeds this value (in lots), the script will only open a trade of the size given in this field.

  9. Subtract open positions volume — if checked, the script will calculate the total open volume for a given trading instrument and will subtract it from the calculated position size, so the resulting volume after a new trade opens is equal to the calculated position size.

  10. Subtract pending orders volume — if checked, the script will calculate the total volume of all pending orders on a given trading instrument and will subtract it from the calculated position size, so the resulting volume after a new trade opens is equal to the calculated position size.

Usage

Using this indicator is very simple if your main aim is to calculate the position size based on your stop-loss and current market parameters.

  1. Attaching Position Size Calculator to a chart will automatically set an entry level to the current price, preparing for a market buy order. Stop-loss level will be set to the nearest low. Take-profit will be turned off.

  2. Now, you can already use its position size output to enter a trade if you planned a market buy order with SL set to the low of the current bar and with 1% of balance risk. You can also change the position size field manually to calculate the risk based on its value.

  3. If not, you can freely change the stop-loss — either by dragging the stop-loss line on chart or by entering the value into the stop-loss input in the panel. You can also set stop-loss as distance in pips by turning on the respective input parameter.

  4. You can set take-profit the same way. Additionally, you can quickly set TP equal to the current SL value (or with some preset multiplier) by clicking the Take-profit button. Similarly to stop-loss, take-profit can be set as distance in pips if the respective input parameter is turned on.

  5. If you turn on ATR settings via the indicator's input parameters, you can also control the ATR values for stop-loss and take-profit calculation.

  6. Adding take-profit will turn on the display of Reward and Reward/risk ratio for your information.

  7. Switching the type of order from Instant to Pending (and backwards) is done with the order type button. When Instant order is used, the Entry level will trail the current price (Bid or Ask) and cannot be manually changed. When Pending order is used, the Entry level can be set either via panel's input or by dragging the chart line.

  8. The indicator will warn if the Entry level is too close to the current price in Pending order mode and if the Stop-loss or Take-profit level are too close to the Entry level.

  9. You can set the size of commission (one-way) applied by your broker if you want your potential loss to be calculated including this cost of trading.

  10. Switching account size from balance to equity or to balance minus portfolio risk can be useful in some cases and is done by a one or two clicks on the respective button.

  11. Adjusting the risk tolerance can be done in two ways: by setting percentage risk value or by setting money risk value. Both are done via input fields in the panel.

  12. Moving on to the Risk tab of the panel is completely optional and provides information about your current and potential risk and reward. You can control how pending orders and orders without stop-loss/take-profit are treated in this tab.

  13. Margin tab is not necessary too if your goal is to calculate the optimal position size based on your risk and stop-loss. This tab will inform you on amount of free and used margin resulting from your position. It will also show you what is the biggest position size that you can open with your current free margin and leverage. A custom leverage can be entered if need arises.

  14. Swaps tab can be consulted if you wish to know how costly the daily rollover will be for your position. It will be especially useful if you are using a carry trade strategy.

  15. Script tab will help you to control how the PSC-Trader script behaves if you use it for position opening.




Input parameters

The indicator has a set of input parameters besides the panel-based controls. Calculator's display options and a number of default options are set via standard MetaTrader inputs.

Position Size Calculator Forex Indicators 6

Compactness

  • ShowLineLabels (default = true) — if true, SL and TP distance in pips will be shown below stop-loss and take-profit lines.

  • DrawTextAsBackground (default = false) — if true, the line labels will be drawn as background. It can be useful if the labels are obscuring something on the chart.

  • PanelOnTopOfChart (default = true) — if true, the panel will be drawn on foreground, and the chart will be drawn as background. Setting it to false will uncover the chart behind the panel.

  • HideAccSize (default = false) — if true, account size display and button will be hidden.

  • ShowPipValue (default = false) — if true, pip value will be displayed in the bottom of the Main tab.

Fonts

  • SL Label Font Color (default = clrLime) — font color for stop-loss line label.

  • TP Label Font Color (default = clrYellow) — font color for take-profit line label.

  • Labels Font Size (default = 13) — font size for the text in labels.

  • Labels Font Face (default = "Courier") — font face for the text in labels.

Lines

  • Entry Line Color (default = clrBlue) — color of the entry line.

  • Stop-Loss Line Color (default = clrLime) — color of the stop-loss line.

  • Take-Profit Line Color (default = clrYellow) — color of the take-profit line.

  • Entry Line Style (default = STYLE_SOLID) — entry line style.

  • Stop-Loss Line Style (default = STYLE_SOLID) — stop-loss line style.

  • Take-Profit Line Style (default = STYLE_SOLID) — take-profit line style.

  • Entry Line Width(default = 1) — entry line width.

  • Stop-Loss Line Width (default = 1) — stop-loss line width.

  • Take-Profit Line Width (default = 1) — take-profit line width.

Defaults

  • Risk (default = 1) — default value for percentage risk. Can be changed via the panel later.

  • EntryType (default = Instant) — default order type. Can be changed via the panel later.

  • Commission (default = 0) — default commission size. Can be changed via the panel later.

  • Commentary (default = "") — default order commentary for PSC-Trader script. Can be changed via the panel later.

  • DefaultSL (default = 0) — if non-zero, the stop-loss level of a newly attached Position Size Calculator will be set to this value in pips.

  • DefaultTP (default = 0) — if non-zero, the take-profit level of a newly attached Position Size Calculator will be set to this value in pips.

Miscellaneous

  • TP_Multiplier (default = 1) — multiplier value for take-profit button.

  • ShowSpread (default = false) — if true, current spread value in ticks will be displayed inside the panel's caption.

  • AdditionalFunds (default = 0) — funds to be added to the account size for the purpose of risk and position size calculation. For example, this could be some funds you hold outside the broker's account but consider a part of your Forex risk capital.

  • UseFixedSLDistance (default = false) — if true, stop-loss will be set in pips and the SL line will be following the entry line.

  • UseFixedTPDistance (default = false) — if true, take-profit will be set in pips and the TP line will be following the entry line.

  • UseCFDMultiplier (default = false) — if true, the tick value used in position size calculation will be multiplied by the contract size when working with CFDs. Toggle this input if your position size seems off by an order of magnitude or two. This parameter is available only in MT5 version of the indicator.

  • ShowATROptions (default = false) — if true, the panel will display options for ATR indicator to be used for SL/TP calculation.

Screenshots

Main tab

The main tab is the biggest one and looks nice on any background — this one is white for example. Take-profit line's color has been changed to orange via an input parameter for better readability.

Position Size Calculator Forex Indicators 7

Risk tab

Black background color and chart grid do not interfere with the panel as you can see on this screenshot of the Risk tab. The risk outputs show Infinity as there is, apparently, a sell order without stop-loss.

Position Size Calculator Forex Indicators 8

Margin tab

Even the wildest color scheme works well with Position Size Calculator. In this case, cyan background is combined with green and red candlesticks. Stop-loss color is set to black.

Position Size Calculator Forex Indicators 9

Swaps tab

This example shows swaps tab with a classic black and white color scheme chart. This broker is charging some serious rollover fees for margin trading in Bitcoin.

Position Size Calculator Forex Indicators 10

Script tab

When the panel is set to background, it becomes transparent and you can easily analyze the exposed chart. At the same time, you are able to see the values used for trading script management on this tab.

Position Size Calculator Forex Indicators 11

Minimized panel

Minimizing the panel in one click makes it completely non-obtrusive and allows trader to easily see the whole chart.

Position Size Calculator Forex Indicators 12

Installation

To install the indicator, make sure that you copy all three files to /MQL4/Indicators/ or /MQL5/Indicators/ (if you are on MetaTrader 5) or to the same subfolder there:

  • Defines.mqh

  • PositionSizeCalculator.mq4 or PositionSizeCalculator.mq5

  • PositionSizeCalculator.mqh

You need to compile PositionSizeCalculator.mq4 (or PositionSizeCalculator.mq5) not the other two.

0 traders reviewed this item, please leave a reply!

About FXYEAH | Broker Listing | Contribute | Contact Us | Sitemap | TagCloud
Disclaimer: All contents of site are only for your reference, don't suggest you do any investment decision, you should be responsible for your decision.