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.
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:
Indicator's version number.
Spread value in ticks.
Minimization button to fold down the panel.
Close button to remove the indicator from the chart.
Main tab switch — it is currently turned on.
Risk tab switch — click it to see the current and potential risk profile. The Risk tab interface is explained below.
Margin tab switch — click it to see everything related to required and free margin. The Margin tab interface is explained below.
Swaps tab switch — click it to see the details on the swaps for the current trading instrument. The Swaps tab interface is explained below.
Script tab switch — click it to see controls for the PSC-Trader script. The Script tab interface is explained below.
Entry input — grayed out when Instant order is used, can be used enter entry level when Pending order is set.
Take-profit button allows quick setting of TP to the level equal to the current SL value.
Take-profit multiplier, if set via input parameters, applies to the current SL value when Take-profit button is pressed.
Order type button to switch between Instant and Pending.
Hide/show lines button to quickly switch the display of the Entry, Take-profit, and Stop-loss lines on the chart.
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.
Account size in account currency units.
Account size asterisk signals that additional funds are set via input parameters; the funds were added to the account size value.
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.
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.
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.
Risk (result) — percentage risk calculated based on the actual position size allowed in your broker's platform.
Risk money (result) — money risk calculated based on the actual position size allowed in your broker's platform.
Reward in account currency is based on the position size calculated without taking into account platform's restrictions.
Reward (result) — reward in account currency is based on the actual position size allowed in your broker's platform.
Reward/risk ratio (result) — reward result divided by risk result.
Position size — actual position size calculation output. You can modify it yourself if you want to calculate your risk based on position size.
Pip value per calculated position size.
Reward/risk (input) — input reward divided by input risk.
ATR Period — setting to use with the ATR-based SL/TP.
ATR — current value of ATR with a given period.
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.
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.
ATR timeframe — timeframe to calculate ATR on. Click the button to switch between timeframes.
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:
Count pending orders — if checked, the indicator will also attempt to calculate the risk of pending orders in addition to currently open positions.
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.
Current portfolio risk (currency) — shows the risk in currency units without the position, which is currently being calculated by this indicator.
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.
Current portfolio risk (%) — same as Current portfolio risk (currency) but in percentage to the account size.
Potential portfolio risk (%) — same as Potential portfolio risk (currency) but in percentage to the account size.
Current portfolio reward (currency) — shows the reward in currency units without the position, which is currently being calculated by this indicator.
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.
Current portfolio reward (%) — same as Current portfolio reward (currency) but in percentage to the account size.
Potential portfolio reward (%) — same as Potential portfolio reward (currency) but in percentage to the account size.
Current portfolio lots — the total size of the currently open positions in lots.
Potential portfolio lots — the total size in lots of the open positions plus the one, which is currently being calculated by this indicator.
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 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.
Future used margin is calculated based on the current used margin and position margin.
Future free margin shows how much free margin you will have left after opening the calculated position.
Default leverage shows the account's actual leverage for your reference.
Maximum position size by margin displays the biggest trade you can take with your currently available free margin and leverage.
Custom leverage input lets you set your own leverage for all the margin calculations done by this indicator.
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.
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:
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.
Triple swap shows the day of week when triple swaps are charged/paid (to account for Saturday and Sunday).
Nominal swaps — nominal swaps paid or charged by a broker for long and short positions.
Daily swap per lot — daily swap paid or charged by a broker for long and short positions in account currency per lot.
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).
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.
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.
Position size duplicates the display of the position size calculated by the indicator on the Main 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.
Magic number — Magic number that will be assigned to the orders and positions opened using the script.
Order commentary — commentary for orders and positions opened using the script.
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.
Max slippage — maximum tolerable slippage value (in broker pips) that will be used in trading functions of the script.
Max spread — the script will not trade if current spread is wider than the value given here.
Max Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes greater than this value.
Min Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes less than this value.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Adding take-profit will turn on the display of Reward and Reward/risk ratio for your information.
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.
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.
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.
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.
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.
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.
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.
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.
Script tab will help you to control how the PSC-Trader script behaves if you use it for position opening.
This video demonstrates how you can use the Position Size Calculator indicator, showcasing most of it functions:
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.
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.
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.
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.
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.
DefaultATRTimeframe (default = PERIOD_CURRENT) — if set to some specific timeframe, a newly attached Position Size Calculator will use this timeframe for ATR calculation.
TP_Multiplier (default = 1) — multiplier value for the take-profit button.
UseCommissionToSetTPDistance (default = false) — if true, the take-profit button will take into account the commission field when calculating the appropriate TP level.
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.
DisableTickValueAdjustment (default = false) — if true, the tick value used in position size calculation will not be adjusted based on the symbol's profit currency and account currency difference. This might be useful when your broker doesn't properly set profit currencies for symbols. Set it to true if you notice discrepancies between the calculated results and what you see in reality.
Input parameters explanation video
This explantion video below demonstrates how changing the parameters described above change the Position Size Calculator's behavior:
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.
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.
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.
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.
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.
Minimizing the panel in one click makes it completely non-obtrusive and allows trader to easily see the whole chart.
Downloads (ver. 2.27, 2019-11-07)
Position Size Calculator is being developed via a dedicated GitHub repository. You are encouraged to actively participate in the improvement of this indicator by submitting your own features via pull-requests and by reviewing existing suggestions, changes, fixes, and so on.
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:
PositionSizeCalculator.mq4 or PositionSizeCalculator.mq5
You need to compile PositionSizeCalculator.mq4 (or PositionSizeCalculator.mq5) not the other two.
This how-to video explains how to install Position Size Calculator in MetaTrader 5 platform, but the process is very similar for MetaTraer 4:
You can use the position size output of this indicator to open trades manually in the same or in some other platform. Additionally, you can use a custom trading script that will open trades based on the calculated position size and with the given entry, SL, and TP levels. Just copy it to /MQL4/Scripts/ (or /MQL5/Scripts/) subfolder of your platform's data folder. After compilation, It will become available in the Navigator subwindow of your trading terminal under Scripts as PSC-Trader. You can also set a hotkey to run this script if you want to open orders really fast. The script's behavior is controlled via Script tab of the Position Size Calculator.
Do you have any suggestions or questions regarding this indicator? You can always discuss Position Size Calculator with other traders and MQL programmers in the forum.
You can also subscribe to our monthly newsletter to keep yourself updated about future changes to Position Size Calculator indicator.
Frequently asked questions
I get compilation errors when compiling Position Size Calculator. How do I solve this?
First, make sure that you are compiling the right file —PositionSizeCalculator.mq4 in MetaTrader 4 or PositionSizeCalculator.mq5 in MetaTrader 5. Second, make sure that the other two files — Defines.mqh and PositionSizeCalculator.mqh — are placed in the same folder as the one you compile. If the problem isn't solved, please post in the official discussion thread, stating the version of Position Size Calculator, version of MetaTrader, and providing a copy or a screenshot of the compilation errors.
I installed the indicator but when I add it to a chart, nothing happens. Why?
Most likely, you need to compile it. To do this, left-click it in the list of indicators in MetaTrader's Navigator window and press Enter. MetaEditor will open the calculator's source code. Now press F7. See the answer to the question above if there are compilation errors.
I am using PSC in MetaTrader 5 and the calculation results seem to be off by a very wide margin. How to fix it?
Try setting UseCFDMultiplier to true.
I am using PSC and the calculation results seem to be somewhat incorrect. How do I fix it?
Try setting DisableTickValueAdjustment to true.
The calculator seems to be calculating trades only for Buy trades (or only for Sell trades). How do I switch from Buy to Sell and vice versa?
If you move the Stop-loss line above the Entry line, it will calculate position size for a Sell trade. If you move the Stop-loss line below the Entry line, it will calculate position size for a Buy trade.
2.27 — 2019-11-07
Fixed errors in CFD margin calculation for non-USD accounts that could occur in some cases in MetaTrader 5.
Fixed division by zero error when calculating portfolio risk for trades with base currency same as the account currency.
Fixed potential portfolio reward calculation when no take-profit is set in the panel.
Fixed default entry and stop-loss positioning when PSC is loaded on a new chart with a default.tpl template.
Changed the way file names for PSC settings are generated — all currently attached panels will be reset when upgrading to version 2.27.
Added DisableTickValueAdjustment input parameter to disable tick value adjustment calculation. It might turn helpful for cases when broker incorrectly reports the symbol's profit currency.
Added input groups in MetaTrader 5.
2.26 — 2019-10-09
Fixed a bug that sometimes prevented finding correct reference currency pair for cases when account currency was different from the symbol's profit currency.
2.25 — 2019-10-05
Fixed compilation errors in MT5 Build 2170 (and newer versions).
2.24 — 2019-08-21
Implemented a more accurate way to calculate risk and reward for portfolios that include currency pairs with the account currency as their base currency.
MT5 only: Fixed interest type swaps calculation for some CFDs when UseCFDMultiplier input parameter is set to true.
2.23 — 2019-08-03
Fixed a glitch with a redundant text label appearing on some tabs.
Added a more accurate way to calculate position size, risk, and reward for currency pairs with base currency same as the account currency.
2.22 — 2019-07-08
Fixed a bug in MT4 version that could cause incorrect calculations for RUB accounts.
Fixed a potential division by zero error when calculating symbol leverage.
The take-profit button can now take into account commission if UseCommissionToSetTPDistance is set to true.
Both TP and SL lines can now be freely moved even when fixed SL/TP distance is used.
ATR timeframe can now be set to different from what the current chart is set to.
2.21 — 2019-03-29
Changed the way the indicator behaves when loading a saved chart template with PSC — the take-profit line is now removed.
Fixed a bug that caused take-profit to reset when switching from normal level to TP based on pip distance.
2.20 — 2019-03-21
Fixed a bug that could cause the DefaultSL and DefaultTP input parameters to be applied slightly incorrectly.
2.19 — 2019-03-14
Fixed a bug that prevented cleanup of the old panel objects after loading a template with PSC in it.
Fixed a potential division by zero error when data for a currency conversion symbol aren't yet available.
Fixed panel hiding outside the chart's borders when resizing the chart window.
2.18 — 2019-02-27
Added ATR options to the calculator's panel (turn on by setting ShowATROptions to true) to calculate stop-loss and take-profit based on the Average True Range indicator.
Added reverse calculation — you can set position size to calculate its risk.
Added display of the potential reward profile to the Risk tab.
Added display of the number of lots to the Risk tab.
Fixed a bug when SL/TP lines could be moved to invalid value; now they will stick to the nearest tick size multiple.
Fixed a bug when Position Size Calculator could not save its settings correctly when working with a trading symbol that had three periods in its name (for example, "EURUSD...").
Fixed a bug with the maximum position size field on the Script tab rounding incorrectly after switching timeframes or restarting the platform.
2.17 — 2018-11-14
Fixed a bug with incorrect take-profit value showing up if UseFixedTPDistance was set to true and DefaultTP was zero.
Fixed a bug that could cause slightly incorrect SL/TP values to show up due to a rounding error.
2.16 — 2018-11-09
Fixed a bug with poor number formatting, which caused wrong calculation results showing up.
2.15 — 2018-11-06
Added an input parameter for adjusting CFD position size calculation (UseCFDMultiplier) when tick value is incorrectly set on the broker's trading server.
Added input parameters for default stop-loss and take-profit values.
Added support for 8 decimal places (down to 0.00000001) in position size calculation for use with cryptocurrencies in MT5.
Added clarification that commission size is set as one-way.
Fixed a reward value not taking into account the given commission size.
Fixed the number of decimal places used in position size display based on symbol's properties.
Fixed multiple bugs when margin and account currencies were not converted to the account currency.
Fixed a bug when loading a chart template with PSC with non-zero take-profit did not show all relevant fields on the panel.
Fixed a bug when adding second position size calculator to the chart was not prevented properly by MetaTrader 4.
Fixed symbol leverage calculation for non-Forex symbols in MT5.
Fixed nominal swap value formatting.
Added two checkboxes to instruct the PSC-Trader script to open a trade taking into account currently open positions or pending orders.
Changed how script uses Maximum position size field — it will now open a trade even if the calculated position size exceeds the given maximum, but will bring the position size down to that maximum.
Fixed trading script execution when working with hedging mode with market execution in MetaTrader 5.
Fixed another bug in MetaTrader 5 PSC-Trader, which prevented proper setting of SL/TP in market execution mode.
2.14 — 2018-05-18
Fixed reward calculation that could be wrong in some cases.
Added capability to set SL and TP as distance in points to the entry line.
2.13 — 2018-02-19
Fixed another bug with wrong position size calculation for non-Forex trading instruments in both MT4 and MT5 versions of the indicator.
2.12 — 2017-12-22
Fixed a bug that resulted in wrong position size and pip value calculated for CFD trading instruments in MetaTrader 5 version of the indicator.
2.11 — 2017-11-08
Fixed a bug that prevented proper panel initialization (e.g. wrong Pending/Instant button state, two panels appearing after template application, etc.).
Fixed a bug in MT5 version that prevented proper change of input parameters.
2.10 — 2017-10-12
The panel's location will now remain unchanged when minimizing and maximizing it.
Changing the indicator's input parameters Risk, EntryType, Commission, and Commentary will now update the respective panel fields without the need to reattach the indicator.
Fixed a bug with the labels — they will now disappear immediately when the ShowLineLabels parameter is changed to false.
2.09 — 2017-08-31
Input parameters now have priority when changing the settings (color/style/width) of the lines (entry/SL/TP). This fixes a bug that caused lines to remain unaltered when you updated the inputs. If you want to change the lines' look, please do it via the indicator's input parameters.
Fixed a bug when, in the MT5 version only, the line label colors depended on the line colors input parameters rather than on the label colors input parameters.
2.08 — 2017-08-25
Added persistence of panel location, status, and parameters through chart profile changes.
Added optional pip value display.
Added account currency code near reward display.
Fixed a minor bug with the hide/show lines button.
MT5 version of PSC-Trader script 1.04 or older will not work with the calculator versions 2.08 and newer.
2.07 — 2017-07-24
Added take-profit button multiplier for fast TP adjustment.
Added spread display in the panel's caption. NB: It uses ticks, not standard pips.
Added input parameter for additional funds to be applied to the account size.
Added default parameters (can be saved in chart templates): Commission, Order Commentary, Take-Profit Multiplier, Show Spread, Additional Funds.
Fixed a bug with the panel's caption disappearing above the screen's top border.
2.06 — 2017-03-14
Fixed a bug with how the panel remembers its minimized/maximized state.
2.05 — 2017-02-18
Fixed two potential division by zero errors.
2.04 — 2016-12-21
Added DPI scaling for high-resolution displays.
Added Magic number and order commentary for trading script.
Reinstated HideAccSize input parameter for compactness.
Reinstated Risk and EntryType input parameters for template convenience.
Fixed compilation errors in latest MT4/MT5 builds.
Fixed a bug with incorrect decimal places count for nominal swap rates.
SL/Entry lines are no longer saved to templates.
2.03 — 2016-11-11
Added 3rd state in balance button: Balance - CPR.
Added tab with Swaps details.
Added tab with Script settings.
Panel now remembers its minimized/maximized state and X/Y position.
Added PanelOnTopOfChart input parameter.
Added display update on timer.
Fixed bug with TP line showing on top of panel when adding TP via button.
Fixed bug with deinitialization on parameters change and recompilation.
Fixed bug with margin calculation when using custom leverage.
Fixed bug with panel disappearing upon change of timeframe.
2.01 — 2016-09-20
Added Symbol leverage display to Margin tab.
Fixed panel resizing bug.
Fixed duplicate panel bug.
2.00 — 2016-09-07
First version of PSC with graphical panel interface.
The legacy version of Position Size Calculator is the text version of the same indicator that was developed and supported during 2012-2016. It is still fully functional and is compatible with the latest builds of MetaTrader platform.
It is less powerful and has a more complex interface than the current panel version, but it can still do the job — calculate the position size based on the given entry/stop-loss levels, risk tolerance, and the current market data, such as account size and currency, and the price of the quote currency of the traded pair relatively to the account currency.
The result is displayed as a text label in the main or separate chart window. Traders can adjust many parameters, both for calculation and for display.
You may choose the legacy version of the PSC over the graphical one if you prefer. However, the former is no longer developed, though bug reports will be considered. Below, follows the description of the legacy version.
ShowPortfolioRisk (default = false) — if true, then portfolio risk will be calculated based on open positions and/or orders.
ShowMargin (default = false) — if true, then margin information for the planned position will be shown.
EntryType (default = Instant) — if Instant, then entry level will trail the current Ask/Bid rate; if Pending, entry is movable and warning is issued if entry is too close to current rate.
EntryLevel (default = 0) — planned position entry price.
StopLossLevel (default = 0) — planned position stop-loss price.
TakeProfitLevel (default = 0) — planned position take-profit price. It is optional and is used only in reward/risk ratio calculation.
Risk (default = 1) — tolerated risk in percentage points of the account balance/equity.
MoneyRisk (default = 0) — tolerated risk in account currency.
CommissionPerLot (default = 0) — your broker's commission per lot charged in account currency. Enter the value charged for one side of the trade, not round-turn.
UseMoneyInsteadOfPercentage (default = false) — if true, then position size will be calculated based on risk tolerance given in money, not percentage.
UseEquityInsteadOfBalance (default = false) — if true, then account equity is used instead of balance in calculations.
DeleteLines (default = false) — if true, Entry and Stop-Loss lines will be deleted on deinitialization. Also, deletes the old lines on initialization. Otherwise, it will leave the lines on chart, so the levels could be restored on subsequent indicator initialization.
CountPendingOrders (default = false) — if true, then portfolio risk calculation will involve pending orders.
IgnoreOrdersWithoutStopLoss (default = false) — if true, orders and positions without stop-loss will not be ignored in portfolio risk calculation.
HideAccSize (default = false) — if true, the account size line will not be shown.
HideSecondRisk (default = false) — if true, the second risk line will not be shown.
HideEmpty (default = false) — if true, the empty line before divider will not be shown.
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, all text label graphical objects used by the indicator will be drawn as background. It can be useful if you want to prevent the indicator from obscuring the chart.
entry_font_color (default = clrBlue) — font color for entry level display.
sl_font_color (default = clrLime) — font color for stop-loss level display.
sl_label_font_color (default = clrLime) — font color for stop-loss line labels.
tp_font_color (default = clrYellow) — font color for take-profit level display.
tp_label_font_color (default = clrYellow) — font color for take-profit line labels.
ps_font_color (default = clrRed) — font color of the position size result.
rp_font_color (default = clrLightBlue) — font color for risk percentage display.
balance_font_color (default = clrLightBlue) — font color for account size display.
rmm_font_color (default = clrLightBlue) — font color for risk money display.
margin_font_color (default = clrSlateBlue) — font color for margin display.
stopout_font_color (default = clrRed) — font color for stop-out or 'not enough money' warning display.
pp_font_color (default = clrLightBlue) — font color for potential profit display.
rr_font_color (default = clrYellow) — font color for reward/risk ratio display.
div_font_color (default = clrSlateGray) — font color for text divider/header.
font_size (default = 12) — font size of the displayed text.
font_face (default = "Courier") — font face of the indicator.
corner (default = CORNER_LEFT_UPPER) — location for the indicator's text. In MT4: 0 — for top-left corner, 1 — top-right, 2 — bottom-left, 3 — bottom-right. In MT5 it's quite obvious.
distance_x (default = 10) — horizontal distance from the corner to the indicator's text.
distance_y (default = 15) — vertical distance from the corner to the indicator's text.
line_height (default = 15) — line height for output. Change it with the font face and size.
entry_line_color (default = clrBlue) — color of the entry line.
stoploss_line_color (default = clrLime) — color of the stop-loss line.
takeprofit_line_color (default = clrYellow) — color of the take-profit line and the reward/risk ratio.
entry_line_style (default = STYLE_SOLID) — entry line style.
stoploss_line_style (default = STYLE_SOLID) — stop-loss line style.
takeprofit_line_style (default = STYLE_SOLID) — take-profit line style.
entry_line_width (default = 1) — entry line width.
stoploss_line_width (default = 1) — stop-loss line width.
takeprofit_line_width (default = 1) — take-profit line width.
MaxNumberLength (default = 14) — the maximum expected number of digits in displayed values.
Using the indicator
Obviously, this indicator is not suitable for trading signals generation. Its purpose is to help Forex traders calculate position size for their allowed risk size and the given position parameters.
If both EntryLevel and StopLossLevel input parameters are set to zero, this indicator will try to put them at some local levels. You can drag the entry/stop-loss lines up and down directly on the chart. Position size value is recalculated every tick and on every line move.
A trader may also set TakeProfitLevel input parameter to see the calculated reward/risk ratio along with the position size.
Additionally, this indicator can track the whole portfolio risk based on the open trades and pending orders. However, the risk tracking is quite limited with this indicator. It is recommended to use a separate Risk Calculator for the purpose of risk analysis.
You can also use it to see the necessary margin and expected changes in margin based on the calculated size of the position.
You can also make it easier to trade based on the calculated position size. Just download our free MetaTrader script to place orders based on this calculator's output.
I change the StopLossLevel, TakeProfitLevel, or EntryLevel input parameters, but output values do not change and the lines remain at their old levels. Why does it happen and how do I fix this?
It happens because DeleteLines input parameter is set to false. This helps to preserve the level values set by moving the lines. If you want the lines to be updated according to the input parameters, please set DeleteLines to true or delete the lines manually.