Position Sizer Expert Advisor for MT4/MT5 - EarnForex News
- Get link
- X
- Other Apps
Position Sizer (MetaTrader expert advisor) calculates how many lots to trade based on:
- Entry and stop-loss levels
- Risk tolerance
- Account size (balance, equity, or even your savings account)
- Account currency
- Currency exchange rates
Its main features include:
- Works with any trading instruments — currency pairs, CFDs, equities, indices, commodities, futures, cryptocurrencies.
- Calculation inputs and results are displayed in 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 take-profit as distance in points.
- Alternatively, you can set them as multiples of ATR (Average True Range).
- If a 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.
- The expert advisor 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 point value for the calculated position size.
- The EA 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.
- Allows opening positions based on the calculations.
- The calculated position can be divided into several trades with different take-profit levels.
- Supports stop limit orders in MetaTrader 5.
This EA is an evolution of our free online tool and the MetaTrader indicator called Position Size Calculator. Position Sizer is available for both MT4 and MT5, but the MT5 version provides slightly better functionality because the platform itself is more advanced.
Interface
Main tab
The main tab of the panel provides the primary control over the EA's functions and serves to output the most important calculation results: the position size, risk, reward, and risk-to-reward ratio. The following controls and outputs are available:
- Direction arrow shows whether the current trade is long (▲) or short (▼). In MT4 version, it is written in words.
- Version number.
- Spread value in ticks.
- Minimization button to fold down the panel.
- Close button to remove the expert advisor from the chart.
- Main tab switch — it is currently turned on.
- Risk tab switch — click on it to see the current and potential risk profile. The Risk tab interface is explained below.
- Margin tab switch — click on it to see everything related to required and free margin. The Margin tab interface is explained below.
- Swaps tab switch — click on it to see the details on the swaps for the current trading instrument. The Swaps tab interface is explained below.
- Trading tab switch — click on it to see the controls for trading operations. The Trading tab interface is explained below.
- Long/Short switch — enables you to quickly switch between long and short trade calculation. The trade direction can also be switched by pressing the Tab key on your keyboard.
- Entry input — grayed out when Instant order is used, can be used enter entry level when Pending order is set.
- 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.
- Stop-loss input.
- 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.
- Take-profit multiplier, if set via input parameters, applies to the current SL value when Take-profit button is pressed.
- Take-profit input.
- Multiple take-profit input fields. Visible if TakeProfitsNumber input parameter is set to a value greater than 1 or if you add them via the panel.
- Stop price input (for stop limit orders, MT5 only).
- ATR Period — setting to use with the ATR-based SL/TP. ATR options are visible only if ShowATROptions input parameter is set to true.
- ATR — current value of ATR with a given period. ATR options are visible only if ShowATROptions input parameter is set to true.
- 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.
- 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.
- Spread Adjustment for SL — if ticked, the spread value will be subtracted from or added to the stop-loss to make the distance count from the price the trade can be closed at. ATR options are visible only if ShowATROptions input parameter is set to true.
- Spread Adjustment for TP — if ticked, the spread value will be subtracted from or added to the take-profit to make the distance count from the price the trade can be closed at. ATR options are visible only if ShowATROptions input parameter is set to true.
- 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.
- Order type button to switch between Instant, Pending, and Stop Limit. You can also switch this by pressing the o key on your keyboard.
- Hide/show lines button to quickly switch the display of the Entry, Take-profit, and Stop-loss lines on the chart. You can also switch this by pressing the h key on your keyboard.
- 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 button switches between balance, equity, and "Balance - CPR"; the latter being account balance less the current portfolio risk as calculated on the Risk tab.
- Account size in account currency units.
- 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.
- Quick risk button #1 — first button to quickly set percentage risk value.
- Quick risk button #2 — second button to quickly set percentage risk value.
- 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 (input) — input reward divided by input risk.
- 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.
- Point value per calculated position size.
- Max PS button to set the position size to the maximum value possible based on the account's free margin. The button only appears if the ShowMaxPSButton input parameter is set to true.
- +/- buttons to quickly increase or decrease entry, stop-loss, take-profit, or stop price values.
- + button to quickly add another take-profit level.
- X button to quickly remove an extra take-profit level.
- Commission units button to switch between commission in percentage and in currency units.
Risk tab
The risk tab can help you assess current and potential risk and reward profile. Using a simple algorithm, the EA 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 expert advisor 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 three checkboxes and see the calculation results in ten output fields:
- Count pending orders — if ticked, the EA will also attempt to calculate the risk of pending orders in addition to currently open positions.
- (A) Ignore orders without stop-loss — if ticked, PS will ignore all risk coming from orders and positions without SL value set. Can be useful if you prefer not to set stop-loss for some of your trades.
- (B) Ignore orders without take-profit — if ticked, PS will ignore all reward coming from orders and positions without TP value set. Can be useful if you prefer not to set take-profit for some of your trades.
- Ignore orders in other symbols — if ticked, will only calculate risk and reward for the current chart's symbol, ignoring all positions and orders in other symbols.
- Current portfolio risk (currency) — shows the risk in currency units without the position that is currently being calculated by this expert advisor.
- Potential portfolio risk (currency) — shows the risk in currency units as if you have already opened a position that is currently calculated by this expert advisor.
- 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 that is currently being calculated by this expert advisor.
- Potential portfolio reward (currency) — shows the reward in currency units as if you have already opened a position that is currently calculated by this expert advisor.
- 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 expert advisor.
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 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.
- Custom leverage input lets you set your own leverage for all the margin calculations done by this expert advisor.
- Default leverage shows the account's actual leverage for your reference.
- 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.
- 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 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. It can be one of several kinds: 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 (Long) — nominal swaps paid or charged by a broker for long positions.
- Nominal swaps (Short) — nominal swaps paid or charged by a broker for short positions.
- Daily swap per lot (Long) — daily swap paid or charged by a broker for long positions in account currency per lot.
- Daily swap per lot (Short) — daily swap paid or charged by a broker for short positions in account currency per lot.
- 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).
- 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).
- 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.
- 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.
- 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.
- 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.
- Position size duplicates the display of the position size calculated by the EA on the Main tab.
Trading tab
The trading tab lets you trade based on the results of the calculation and also to control the trading process.
- Trade — a button to open a trade (or multiple trades) based on the position size calculation results.
- Trailing stop — a number of points to apply as a trailing stop to trades with the given Magic number.
- Breakeven — a number of points in profit when a breakeven will be applied to a trade with the given Magic number.
- Magic number — Magic number that will be assigned to the orders and positions opened using the expert advisor.
- Order commentary — commentary for orders and positions opened using the expert advisor.
- Auto-suffix — if ticked, the EA will append a unique suffix to the order commentary set up above. This can be particularly useful when you want to set the same commentary for all parts of a multi-TP trade, but you want the next multi-TP trade to use a different commentary.
- Max # of trades — if opening a new trade will make the number of open trades exceed the maximum value, the EA won't open the trade.
- All symbols — if ticked, the EA will count trades for all symbols (not only for the current one) when considering the maximum allowed number of trades, volume, and risk.
- Disable trading when lines are hidden — a simple checkbox to prevent the EA from opening a position when you have chosen to hide the lines via the Main tab.
- Fill take-profits inwards — a button to fill multiple take-profit fields equidistantly from Entry level to main Take-Profit level.
- Fill take-profits outwards — a button to fill multiple take-profit fields equidistantly with the main Take-Profit level as the closest one.
- Multiple take-profit levels — a number (set via TakeProfitsNumber 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.
- Shares to divide the position size — each take-profit level is assigned its percentage of the total position size calculated on the Main tab.
- Max slippage — the maximum tolerable slippage value (in points) that will be used in trading functions of the expert advisor.
- Max spread — the EA will not trade if current spread is wider than the value given here.
- Max Entry/SL distance — the EA will not trade if distance between the Entry level and Stop-Loss level becomes greater than this value.
- Min Entry/SL distance — the EA will not trade if distance between the Entry level and Stop-Loss level becomes less than this value.
- Max position size — if non-zero value is given, the EA will not open a new trade if the total volume of all open positions exceeds the given value.
- Subtract open positions volume — if ticked, the EA 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 ticked, the EA 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.
- Do not apply stop-loss — if ticked, the EA 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.
- Do not apply take-profit — if ticked, the EA 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.
- Ask for confirmation — if ticked, the EA will ask for confirmation before trading.
- Max total risk — if non-zero value is given, the EA will not open a new trade if the total calculated risk of all orders exceeds the given value.
- Share, % — a button to distribute the volume shares between multiple take-profits. It switches between three modes: equal, descending, ascending.
Usage
Using this expert advisor is very simple if your main aim is to calculate the position size based on your stop-loss and the current market parameters and then to execute the trade based on that calculated position size.
- Attaching Position Sizer 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 on.
- 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 the chart or by entering the value into the stop-loss input in the panel. You can also set your stop-loss as a distance in points by turning on the respective input parameter.
- You can set your take-profit the same way. Additionally, you can quickly set the TP equal to the current SL value (or with some preset multiplier) by clicking the Take-profit button. Similar to the stop-loss, the take-profit can be set as distance in points if the respective input parameter is turned on. Multiple take-profit levels are supported when TakeProfitsNumber input parameter is set to a value greater than 1. You can also add and remove take-profits using the panel buttons.
- If you turn ATR settings on via the EA's input parameters, you can also control the ATR values for stop-loss and take-profit calculation.
- Adding a 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 changed manually. When Pending or Stop Limit (in MT5) order is used, the Entry level can be set either via panel's input or by dragging the chart line.
- The EA will warn if the Entry level is too close to the current price in the Pending order mode and if the Stop-loss or Take-profit level is 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 the account size from balance to equity or to balance minus portfolio risk can be useful in some cases and is done by one or two clicks on the respective button.
- Adjusting the risk tolerance can be done in two ways: by setting the percentage risk value or by setting the money risk value. Both are done via the input fields in the panel. You can also use the quick risk setting buttons if you need to switch risk per trade often.
- 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.
- The Margin tab is not necessary either if your goal is to calculate the optimal position size based on your risk and stop-loss. This tab will inform you on the 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.
- The 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.
- The Trading tab will help you to execute the actual trade and control how it is done.
Trading
You can use the position size output of this EA to open trades manually in the same or some other platform. Alternatively, you can use its trading capability to open trades based on the calculated position size and with the given entry, SL, and TP levels. You can either use the Trade button on the Trading tab or the hotkey (set via input parameters).
Trade execution example with confirmation to open a position:
Autotrading should be enabled for trading to work. Here is how to enable it in MetaTrader 4:
And here is how to enable Algo Trading in MetaTrader 5:
How to set a keyboard shortcut for trade execution
You can set a keyboard shortcut via the TradeHotKey input parameter. You can either use a single key (e.g., "T") or with a combination of Shift and Ctrl keys (e.g., "Ctrl+Shift+T").
Warning! There is a known issue with using the keyboard shortcut in MT4. If either Shift or Ctrl is used and the Ask for confirmation option is turned on, the shortcut stops working after the first time the confirmation popup appears. That is why the default value for the shortcut in MT4 is just "T". This problem is absent in MT5.
Demonstration video
This video demonstrates how you can use the Position Sizer expert advisor, showcasing its most important functions:
Input parameters
The EA has a set of input parameters besides the panel-based controls. The Position Sizer's display options and a number of default options are set via standard MetaTrader inputs.
Compactness
- ShowLineLabels (default = true) — if true, SL and TP distance in points 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.
- HideAccSize (default = false) — if true, the account size display and button will be hidden.
- ShowPointValue (default = false) — if true, the point value will be displayed in the bottom of the Main tab.
- ShowMaxPSButton (default = false) — if true, the maximum position size button will be displayed near the position size field.
- StartPanelMinimized (default = false) — if true, the panel will be created in a minimized state.
- ShowATROptions (default = false) — if true, the panel will display options for ATR indicator to be used for SL/TP calculation.
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.
- Stop Price Label Font Color (default = clrPurple) — font color for stop price 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) — the default trade direction. Can be Long or Short.
- SL (default = 0) — if non-zero, the stop-loss level of a newly attached Position Sizer will be set to this value in points. 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 Sizer will be set to this value in points.
- TakeProfitsNumber (default = 1) — if greater than 1, multiple take-profit levels will be available on the Trading tab to split the position in several trades with different take-profits.
- EntryType (default = Instant) — the 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) — the default period for ATR indicator.
- ATRMultiplierSL (default = 0) — the default multiplier for ATR value when calculating ATR-based stop-loss.
- ATRMultiplierTP (default = 0) — the 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 Sizer will use this timeframe for ATR calculation.
- SpreadAdjustmentSL (default = false) — the default state of the spread adjustment checkbox for the ATR-based stop-loss field. If true, the ATR-based stop-loss level will be adjusted by the spread value.
- SpreadAdjustmentTP (default = false) — the default state of the spread adjustment checkbox for the ATR-based take-profit field. If true, the ATR-based take-profit level will be adjusted by the spread value.
- Commission (default = 0) — the default commission size.
- CommissionType (default = Currency units) — the default commission type.
- AccountButton (default = Balance) — the default state of the Account button. Can be Balance, Equity, or Balance - Risk (account balance minus the current portfolio risk).
- Risk (default = 1) — the 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) — the default value for the Count pending orders checkbox on the Risk tab.
- IgnoreOrdersWithoutSL (default = false) — the default value for the Ignore orders without stop-loss checkbox on the Risk tab.
- IgnoreOrdersWithoutTP (default = false) — the default value for the Ignore orders without take-profit checkbox on the Risk tab.
- IgnoreOtherSymbols (default = false) — the default value for the Ignore orders in other symbols checkbox on the Risk tab.
- CustomLeverage (default = 0) — the default value for the Custom leverage field on the Margin tab.
- MagicNumber (default = 2022052714) — the default Magic number for the Trading tab.
- Commentary (default = "") — the default order commentary for trades.
- AutoSuffix (default = false) — if true, a suffix will be automatically appended to the order commentary.
- DisableTradingWhenLinesAreHidden (default = false) — the default value for the Disable trading when lines are hidden checkbox on the Trading tab.
- MaxSlippage (default = 0) — the default value for the maximum slippage on the Trading tab.
- MaxSpread (default = 0) — the default value for the maximum spread on the Trading tab.
- MaxEntrySLDistance (default = 0) — the default maximum entry/SL distance for the Trading tab.
- MinEntrySLDistance (default = 0) — the default minimum entry/SL distance for the Trading tab.
- SubtractOPV (default = false) — the default value for the Subtract open positions volume checkbox on the Trading tab.
- SubtractPOV (default = false) — the default value for the Subtract pending orders volume checkbox on the Trading tab.
- DoNotApplyStopLoss (default = false) — the default value for the Do not apply stop-loss checkbox on the Trading tab.
- DoNotApplyTakeProfit (default = false) — the default value for the Do not apply take-profit checkbox on the Trading tab.
- AskForConfirmation (default = true) — the default value for the Ask for confirmation checkbox on the Trading tab.
- PanelPositionX (default = 0) — the default horizontal distance from the selected panel position corner.
- PanelPositionY (default = 15) — the default vertical distance from the selected panel position corner.
- PanelPositionCorner (default = CORNER_LEFT_UPPER) — the default panel position corner.
- TPLockedOnSL (default = false) — the default state of the take-profit "lock" on the stop-loss. If true, the take-profit tracks the stop-loss distance automatically.
- TrailingStop (default = 0) — the default trailing stop value in points for the Trading tab.
- BreakEven (default = 0) — the default breakeven value in points for the Trading tab.
- MaxNumberOfTrades (default = 0) — the default maximum number of trades to tolerate in the account. The zero value means no limit.
- MaxTotalRisk (default = 0) — the default maximum total risk to tolerate in the account. The zero value means no limit.
- AllSymbols (default = true) — the default state of the All symbols checkbox for the maximum number of trades limit. If true, the EA will count trades on all symbols. If false, the EA will only count trades on the current symbol.
Keyboard shortcuts
- TradeHotKey (default = "Shift+T") — a case-insensitive hotkey shortcut to open a new trade based on the calculations. Supports Shift and Ctrl modifiers.
- SwitchOrderTypeHotKey (default = "O") — a case-insensitive hotkey shortcut to switch the order type. Supports Shift and Ctrl modifiers.
- SwitchEntryDirectionHotKey (default = "TAB") — a case-insensitive hotkey shortcut to switch the trade direction. Supports Shift and Ctrl modifiers.
- SwitchHideShowLinesHotKey (default = "H") — a case-insensitive hotkey shortcut to toggle lines' visibility. Supports Shift and Ctrl modifiers.
Miscellaneous
- TP_Multiplier (default = 1) — the 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 expert advisor. For example, if you are calculating position size for another account. This parameter will override the AdditionalFunds parameter.
- SLDistanceInPoints (default = false) — if true, stop-loss will be set in points and the SL line will be following the entry line.
- TPDistanceInPoints (default = false) — if true, take-profit will be set in points and the TP line will be following the entry line.
- ATRCandle (default = Current candle) — which candle to use to get the ATR value from — current or previous.
- CalculateUnadjustedPositionSize (default = false) — if true, position size calculation result will not be adjusted using broker's minimum/maximum volume and volume step parameters.
- SurpassBrokerMaxPositionSize (default = false) — if true, the EA will surpass the broker's maximum volume limit by opening multiple trades.
- 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) — the 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) — the 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 = "PS_") — the prefix for chart objects' names. It lets Position Sizer avoid conflicts with other chart tools.
- SymbolChange (default = SYMBOL_CHART_CHANGE_EACH_OWN) — what to do when chart's symbol changes:
- SYMBOL_CHART_CHANGE_EACH_OWN — each symbol will try to load each own settings if they exist.
- SYMBOL_CHART_CHANGE_HARD_RESET — a hard reset of all panel settings will occur.
- SYMBOL_CHART_CHANGE_KEEP_PANEL — panel settings will be kept unchanged.
- DisableStopLimit (default = false) — if true, the Stop Limit order type will be skipped when switching through order types via the panel. This is relevant only in MT5.
- TradeSymbol (default = "") — if a non-empty value is given, it will be used as a trading symbol for trading. This can be useful when trading custom symbols in MT5.
- DisableTradingSounds (default = false) — if true, no sounds will be played during trade execution.
- IgnoreMarketExecutionMode (default = true) — if true, the Market execution mode will be ignored for during the trade opening process. Set to false if you experiencing issues opening trades with stop-loss and take-profit.
- MarketModeApplySLTPAfterAllTradesExecuted (default = false) — if true, SL and TP levels will be applied to positions only after all trades finish executing in the Market execution mode. This is relevant only if IgnoreMarketExecutionMode is set to false and symbol uses Market execution.
Demonstration video on input parameters
You can see a visual demonstration of how the Position Sizer's input parameters (as of version 3.00) work in this detailed video:
Screenshots
Main tab
The main tab is the biggest one and looks nice on any background — this one is white for example. The take-profit line's color has been changed to orange via an input parameter for better readability. The order type is set to Stop Limit here, so the purple stop price line is also visible on the chart.
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.
Margin tab
Even the wildest color scheme works well with Position Sizer. In this case, cyan background is combined with green and red candlesticks. Stop-loss color is set to black.
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.
Trading 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 purposes.
Minimized panel
Minimizing the panel in one click makes it completely non-obtrusive and allows trader to easily see the entire chart.
Downloads (ver. 3.03, 2023-03-29)
Position Sizer for MetaTrader 4 Position Sizer for MetaTrader 5Position Sizer is being developed via a dedicated GitHub repository. You are encouraged to actively participate in the improvement of this EA by submitting your own features via pull-requests and by reviewing existing suggestions, changes, fixes, and so on.
Installation
To install the expert advisor, make sure that you copy the entire folder from the archive to /MQL4/Experts/ or /MQL5/Experts/ (if you are on MetaTrader 5).
The EA folder should contain the following files:
- Defines.mqh
- Position Sizer.mq4 or Position Sizer.mq5
- Position Sizer.mqh
- Position Sizer Trading.mqh
- errordescription.mqh (MT5 only)
You need to compile Position Sizer.mq4 (or Position Sizer.mq5), not any of the other files.
This how-to video explains how to install the Position Sizer EA for MetaTrader 5, but the process is quite similar for MetaTraer 4:
Frequently asked questions
I get compilation errors when compiling Position Sizer. How do ...
- Get link
- X
- Other Apps
Comments
Post a Comment