Position Size Calculator MetaTrader indicator | FREE Forex Trading Indicator

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. The trading script can also divide the position into several trades with different take-profit levels.
  • Supports stop limit orders in MetaTrader 5.

This indicator is an evolution 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:

  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. Long/Short switch — enables you to quickly switch between long and short trade calculation.
  11. Entry input — grayed out when Instant order is used, can be used enter entry level when Pending order is set.
  12. Stop-loss button will set stop-loss level to a given default value. Visible only if a non-zero default stop-loss is set via SL input parameter.
  13. Stop-loss input.
  14. Take-profit button allows quick setting of TP to the multiple of the current SL value or to peg the TP level to the SL value.
  15. Take-profit multiplier, if set via input parameters, applies to the current SL value when Take-profit button is pressed.
  16. Take-profit input.
  17. Multiple take-profit input fields. Visible if ScriptTakePorfitsNumber input parameter is set to a value greater than 1.
  18. Stop price input (for stop limit orders).
  19. ATR Period — setting to use with the ATR-based SL/TP. ATR options are visible only if ShowATROptions input parameter is set to true.
  20. ATR — current value of ATR with a given period. ATR options are visible only if ShowATROptions input parameter is set to true.
  21. 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. ATR options are visible only if ShowATROptions input parameter is set to true.
  22. 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 options are visible only if ShowATROptions input parameter is set to true.
  23. ATR timeframe — timeframe to calculate ATR on. Click the button to switch between timeframes. ATR options are visible only if ShowATROptions input parameter is set to true.
  24. Order type button to switch between Instant, Pending, and Stop Limit.
  25. Hide/show lines button to quickly switch the display of the Entry, Take-profit, and Stop-loss lines on the chart.
  26. 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.
  27. 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.
  28. Account size in account currency units.
  29. Account size asterisk signals that either custom account balance or additional funds are set via input parameters; the funds were added to the account size value.
  30. Quick risk button #1 — first button to quickly set percentage risk value.
  31. Quick risk button #2 — second button to quickly set percentage risk value.
  32. 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.
  33. 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.
  34. Risk (result) — percentage risk calculated based on the actual position size allowed in your broker’s platform.
  35. Risk money (result) — money risk calculated based on the actual position size allowed in your broker’s platform.
  36. Reward in account currency is based on the position size calculated without taking into account platform’s restrictions.
  37. Reward (result) — reward in account currency is based on the actual position size allowed in your broker’s platform.
  38. Reward/risk (input) — input reward divided by input risk.
  39. Reward/risk ratio (result) — reward result divided by risk result.
  40. Position size — actual position size calculation output. You can modify it yourself if you want to calculate your risk based on position size.
  41. Pip value per calculated position size.

Risk tab

The risk tab can assist you in determining your current and potential risk and reward profile. The indicator calculates the risk of open positions and pending orders based on their stop-loss levels using a simple algorithm (or lack thereof). It also considers the potential reward of previously opened positions as well as the position calculated by the indicator based on take-profit levels. The risk analysis method used does not take into account complex situations involving hedged orders and positions. For a more in-depth portfolio risk analysis, use the Risk Calculator indicator. The Risk tab is controlled by two checkboxes, and the calculation results are displayed in ten output fields:

Position Size Calculator - Indicator's Interface - Risk Tab
  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. Ignore orders in other symbols — if checked, will only calculate risk and reward for the current chart’s symbol, ignoring all positions and orders in other symbols.
  4. Current portfolio risk (currency) — shows the risk in currency units without the position that is currently being calculated by this indicator.
  5. Potential portfolio risk (currency) — shows the risk in currency units as if you have already opened a position that is currently calculated by this indicator.
  6. Current portfolio risk (%) — same as Current portfolio risk (currency) but in percentage to the account size.
  7. Potential portfolio risk (%) — same as Potential portfolio risk (currency) but in percentage to the account size.
  8. Current portfolio reward (currency) — shows the reward in currency units without the position that is currently being calculated by this indicator.
  9. Potential portfolio reward (currency) — shows the reward in currency units as if you have already opened a position that is currently calculated by this indicator.
  10. Current portfolio reward (%) — same as Current portfolio reward (currency) but in percentage to the account size.
  11. Potential portfolio reward (%) — same as Potential portfolio reward (currency) but in percentage to the account size.
  12. Current portfolio lots — the total size of the currently open positions in lots.
  13. 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 - Indicator's Interface - Margin Tab
  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. Custom leverage input lets you set your own leverage for all the margin calculations done by this indicator.
  5. Default leverage shows the account’s actual leverage for your reference.
  6. 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.
  7. Maximum position size by margin displays the biggest trade you can take with your currently available free margin and leverage.

Swaps tab

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

Position Size Calculator - Indicator's Interface - Swaps Tab
  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 (Long) — nominal swaps paid or charged by a broker for long positions.
  4. Nominal swaps (Short) — nominal swaps paid or charged by a broker for short positions.
  5. Daily swap per lot (Long) — daily swap paid or charged by a broker for long positions in account currency per lot.
  6. Daily swap per lot (Short) — daily swap paid or charged by a broker for short positions in account currency per lot.
  7. Daily swap per PS (Long) — daily swap paid or charged by a broker for long positions in account currency for calculated position size (on the Main tab).
  8. Daily swap per PS (Short) — daily swap paid or charged by a broker for short positions in account currency for calculated position size (on the Main tab).
  9. Yearly swap per lot (Long) — swap paid or charged by a broker for long positions in account currency per lot. Calculated for a period of 360 days.
  10. Yearly swap per lot (Short) — swap paid or charged by a broker for short positions in account currency per lot. Calculated for a period of 360 days.
  11. Yearly swap per PS (Long) — swap paid or charged by a broker for long positions in account currency for calculated position size (on the Main tab). Calculated for a period of 360 days.
  12. Yearly swap per PS (Short) — swap paid or charged by a broker for short positions in account currency for calculated position size (on the Main tab). Calculated for a period of 360 days.
  13. Position size duplicates the display of the position size calculated by the indicator on the Main tab.

Script tab

The script tab allows you to have some control over the trading script. If you are not using PSC-Trader, you can skip this tab.

Position Size Calculator - Indicator's Interface - Script Tab
  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. Fill take-profits inwards — a button to fill multiple take-profit fields equidistantly from Entry level to main Take-Profit level.
  5. Fill take-profits outwards — a button to fill multiple take-profit fields equidistantly with the main Take-Profit level as the closest one.
  6. Multiple take-profit levels — a number (set via ScriptTakePorfitsNumber input parameter) of take-profits to divide the position among. The first take-profit is always the same as the one set on the Main tab.
  7. Shares to divide the position size — each take-profit level is assigned its percentage of the total position size calculated on the Main tab.
  8. Max slippage — maximum tolerable slippage value (in broker pips) that will be used in trading functions of the script.
  9. Max spread — the script will not trade if current spread is wider than the value given here.
  10. Max Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes greater than this value.
  11. Min Entry/SL distance — the script will not trade if distance between the Entry level and Stop-Loss level becomes less than this value.
  12. 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.
  13. 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.
  14. 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.
  15. Do not apply stop-loss — if checked, the script will open a trade without stop-loss. This can be useful if you use a separate expert advisor or some other means to trigger your stop-loss.
  16. Do not apply take-profit — if checked, the script will open a trade without take-profit. This can be useful if you use a separate expert advisor or some other means to trigger your take-profit.
  17. Ask for confirmation — if checked, the script will ask for confirmation before trading.

Usage

If your main goal is to calculate position size based on your stop-loss and current market parameters, this indicator is very simple to use.

  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. Multiple take-profit levels are supported when ScriptTakePorfitsNumber input parameter is set to a value greater than 1.
  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 a 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. You can also use quick risk setting buttons if you need to switch risk per trade often.
  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.

Demonstration video

This video demonstrates how you can use the Position Size Calculator indicator, showcasing most of it functions:

Input parameters

Aside from the panel-based controls, the indicator has a set of input parameters. Standard MetaTrader inputs are used to configure the calculator’s display options as well as a number of default options.

Position Size Calculator - Input Parameters

Compactness

  • ShowLineLabels (default = true) — if true, SL and TP distance in pips will be shown below the stop-loss and take-profit lines.
  • ShowAdditionalSLLabel (default = false) — if true, percentage and money risk will be displayed above the stop-loss line.
  • ShowAdditionalTPLabel (default = false) — if true, percentage and money targets and a risk-to-reward ratios will be displayed above the take-profit lines. If multiple take-profits are used, the relevant trade size will also be displayed there.
  • 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.
  • Stop Price Line Color (default = clrPurple) — color of the stop price line for stop limit orders (MT5 only).
  • 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.
  • Stop Price Line Style (default = STYLE_DOT) — stop price line style for stop limit orders (MT5 only).
  • 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.
  • Stop Price Line Width (default = 1) — stop price line width for stop limit orders (MT5 only).

Defaults

All default parameters can be changed via the panel. They are added here for the sake of convenience — you can save them to a settings file or to create chart templates.

  • TradeDirection (default = Long) — default trade direction. Can be Long or Short.
  • SL (default = 0) — if non-zero, the stop-loss level of a newly attached Position Size Calculator will be set to this value in pips. Will also turn on the Stop-loss button on the main tab.
  • TP (default = 0) — if non-zero, the take-profit level of a newly attached Position Size Calculator will be set to this value in pips.
  • EntryType (default = Instant) — default order type. Can be Instant or Pending.
  • ShowLines (default = true) — if true, SL, TP, and Entry lines won’t be hidden.
  • LinesSelected (default = true) — if true, SL, TP, and Entry lines will be selected for moving. Be careful not to delete them occasionally!
  • ATRPeriod (default = 14) — default period for ATR indicator.
  • ATRMultiplierSL (default = 0) — default multiplier for ATR value when calculating ATR-based stop-loss.
  • ATRMultiplierTP (default = 0) — default multiplier for ATR value when calculating ATR-based take-profit.
  • ATRTimeframe (default = PERIOD_CURRENT) — if set to some specific timeframe, a newly attached Position Size Calculator will use this timeframe for ATR calculation.
  • Commission (default = 0) — default commission size.
  • AccountButton (default = Balance) — default state of the Account button. Can be Balance, Equity, or Balance_minus_Risk (account balance minus the current portfolio risk).
  • Risk (default = 1) — default value for percentage risk.
  • MoneyRisk (default = 0) — if greater than zero, will be used as the default value for money risk and the percentage risk will be calculated based on the money risk.
  • CountPendingOrders (default = false) — default value for the Count pending orders checkbox on the Risk tab.
  • IgnoreOrdersWithoutStopLoss (default = false) — default value for the Ignore orders without stop-loss/take-profit checkbox on the Risk tab.
  • CustomLeverage (default = 0) — default value for the Custom leverage field on the Margin tab.
  • MagicNumber (default = 0) — default Magic number for the Script tab.
  • Commentary (default = “”) — default order commentary for PSC-Trader script.
  • DisableTradingWhenLinesAreHidden (default = false) — default value for the Disable trading when lines are hidden checkbox on the Script tab.
  • MaxSlippage (default = 0) — default value for the maximum slippage on the Script tab.
  • MaxSpread (default = 0) — default value for the maximum spread on the Script tab.
  • MaxEntrySLDistance (default = 0) — default maximum entry/SL distance for Script tab.
  • MinEntrySLDistance (default = 0) — default minimum entry/SL distance for Script tab.
  • SubtractOPV (default = false) — default value for the Subtract open positions volume checkbox on the Script tab.
  • SubtractPOV (default = false) — default value for the Subtract pending orders volume checkbox on the Script tab.
  • DoNotApplyStopLoss (default = false) — default value for the Do not apply stop-loss checkbox on the Script tab.
  • DoNotApplyTakeProfit (default = false) — default value for the Do not apply take-profit checkbox on the Script tab.
  • AskForConfirmation (default = false) — default value for the Ask for confirmation checkbox on the Script tab.
  • PanelPositionX (default = 0) — default horizontal distance from the selected panel position corner.
  • PanelPositionY (default = 15) — default vertical distance from the selected panel position corner.
  • PanelPositionCorner (default = CORNER_LEFT_UPPER) — default panel position corner.
  • TPLockedOnSL (default = false) — default state of take-profit “lock” on stop-loss. If true, take-profit tracks the stop-loss distance automatically.

Miscellaneous

  • 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.
  • CustomBalance (default = 0) — you can set custom balance size for the calculator. For example, if you are calculating position size for another account. This parameter will override the AdditionalFunds parameter.
  • 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.
  • ShowATROptions (default = false) — if true, the panel will display options for ATR indicator to be used for SL/TP calculation.
  • ScriptTakePorfitsNumber (default = 1) — if greater than 1, multiple take-profit levels will be available on the Script tab to let the PSC-Trader script to split the position in several trades with different take-profits.
  • CalculateUnadjustedPositionSize (default = false) — if true, position size calculation result will not be adjusted using broker’s minimum/maximum volume and volume step parameters.
  • RoundDown (default = true) — if true, position size and potential reward are rounded down. If false, normal math rounding rule is used. Switching to false may lead you to risking more than you planned.
  • QuickRisk1 (default = 0) — percentage risk value to be assigned to the first quick button. Alongside with the second quick risk button, it enables you to quickly set a specific risk level.
  • QuickRisk2 (default = 0) — percentage risk value to be assigned to the second quick button. Alongside with the first quick risk button, it enables you to quickly set a specific risk level.
  • ObjectPrefix (default = “PSC_”) — prefix for chart objects’ names. It lets Position Size Calculator avoid conflicts with other chart tools.

Input parameters explanation video

This explanation video below demonstrates how changing the parameters described above change the Position Size Calculator’s behavior:

Screenshots

Main tab

The main tab is the largest and looks good on any background, such as this one, which is white. The colour of the take-profit line has been changed to orange via an input parameter for better readability. The order type is set to Stop Limit in this case, so the purple stop price line is visible on the chart as well.

Position Size Calculator - Main Tab on White Background

Risk tab

As you can see in this screenshot of the Risk tab, the black background colour and chart grid do not interfere with the panel. The risk outputs show Infinity because there appears to be a sell order with no stop-loss.

Position Size Calculator - Risk Tab on Black Background

Margin tab

Position Size Calculator works well with even the most outlandish colour schemes. The cyan background is combined with green and red candlesticks in this case. The colour of the stop-loss is set to black.

Position Size Calculator - Margin Tab on Cyan Background

Swaps tab

This example combines the swaps tab with a traditional black and white colour scheme chart. This broker imposes significant rollover fees for margin trading in Bitcoin.

Position Size Calculator - Swaps Tab on White Background

Script tab

When you set the panel to background, it becomes transparent, allowing you to easily analyse the exposed chart. On this tab, you can see the values used for trading script management at the same time.

Position Size Calculator - Script Tab with Panel as Background

Minimized panel

When the panel is minimised with a single click, it becomes completely unobtrusive and allows the trader to see the entire chart.

Position Size Calculator - Minimized Panel

Downloads (ver. 2.39, 2021-07-14)

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.

Position Size Calculator for MetaTrader 4

Position Size Calculator for MetaTrader 5

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.

This how-to video explains how to install Position Size Calculator in MetaTrader 5 platform, but the process is very similar for MetaTraer 4: https://www.youtube.com/embed/T7xSzjlMKI4

Trading script

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. https://www.youtube.com/embed/zrrOsJ5iNV4

Trading script execution example with confirmation to open a position:

PSC-Trader script - Order confirmation window

Download the script (ver. 1.12, 2021-04-06)

How to set a keyboard shortcut for PSC-Trader script

After installing the script, you can add add a hotkey for a quick access.

Adding a hotkey (keyboard shortcut) to the script will make placing trades nearly instantaneous. Here is a short tutorial on how to add a hotkey to the script in MetaTrader:

1. Right-click on the script in the Navigator panel of your MetaTrader:

MetaTrader - How to Set Hotkey for a Script

2. Then set a control key for your shortcut. It can be either Ctrl or Alt:

Selecting a Control Key for a Hotkey

3. Now you can set the main trigger key:

Setting the Main Key for a Keyboard Shortcut

4. Done! You can now press the selected key combination to invoke the script at any time to open your trade immediately.

PS: Of course, you should enable Autotrading in your platform for the script to work, whether you start it with a mouse click or a key press:

MetaTrader - Allowing Autotrading for Scripts

Credits: EarnForex


You May Also Like ❤ :

Leave a Reply

Your email address will not be published. Required fields are marked *