If I am not wrong , the code in link you posted solves when you want to get lotsize from % of balance.

The code I linked to does illustrate position sizing using percentage of balance. But the main formula (lotsize = risk amount / stoploss value) is true for both percentage of balance and fixed risk amounts.

My question is, how can I improve the formula and make it finally usable? Should I multiply stoploss with PointValue like you do? Would that be a solution?

I can't answer your questions definitively because you haven't posted any of your code in which you attempt to "improve" the formula and "make it finally usable". This is partially why I gave you just the main formula (lotsize = risk amount / stoploss value). How you calculate both risk amount and stoploss value is up to you in your code (although, I caution you that calculating the stoploss value can be a bit tricky...and the subject of much debate on this site.). If you attempt to code it and encounter problems, post your attempted code here and several of us can try to help.

"although, I caution you that calculating the stoploss value can be a bit tricky...and the subject of much debate on this site."

Yes, plenty of opinions, topics and codes... That's why I asked for the solution, because I can't figure it out by myself. There's just too much of that everywhere and no solution. I didn't want to anyone to write an EA for me, I just wanted one function. What's wrong with that? If that's such a problem, sorry for bothering you.

Yes, plenty of opinions, topics and codes... That's why I asked for the solution, because I can't figure it out by myself. There's just too much of that everywhere and no solution.

I understand. There is allot of topics, conversations, and opinions regarding how to calculate lot size. There is no easy answer...there are times where you have to wade through the minutiae just to find the right answer.

Is your SLoss denominated in points or pips? To use PointValue, as I've used in my equation, stoploss must be distance denominated in points.

So, let's say that PointValue is 1.0 (standard account with USD deposit currency on a EUR/USD chart) and your stoploss is 1000 points (100 pips) and your fixed risk amount is $80.

The equation is: lotsize = 80 / (1000 * 1.0)

Therefore, lotsize = 0.08 (that is 8 microlots on a standard account).

That is why, using the code that I used in my equation, SLoss must be denominated in points, not pips. (If you used pips, rather than points, the equation would be: lotsize = 80 / (100 * 1.0), which is 0.80 (8 minilots) and a 10 times larger position then you wanted. However, you can change the equation to use pips...I just found it easier to use points.)

There is also a question of minimum and maximum lotsize and the lotstep. The minimum and maximum lotsize are self-explanatory...your lotsize must be equal to or greater than the minimum and must be less than or equal to the maximum. Lotstep determines the least significant digit for lotsize between the minimum and maximum. For example, if the minimum lotsize is 0.10 and lotstep is 0.01, then you can use lotsizes 0.10, 0.11, 0.12, etc, but not 0.09.

Review the code that I linked to to get an idea about minimum and maximum lotsize and lotstep.

Had you bothered to look at my DeltaPerLot link you wouldn't have seen any /Point and you would have known why. Drop the /Point. On currencies Ticksize == point but on metals they don't.

double Lotsize = Risk_USD/SLoss*PointValue;

We have no idea what SLoss is but it had better be a change in price, not pips or points.

Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)

Look at the equation and your derivation again. Don't you want Risk_USD/ ( SLoss * PointValue )or Risk_USD/SLoss / PointValue?

On currencies Ticksize == point but on metals they don't.

I trade in the US, so unfortunately, I am restricted by law and CFTC rule from trading precious metals in my forex account. Since I can't trade metals in my forex account, I generally don't code for them; and my code and functions reflect that fact!

Had you bothered to look at my DeltaPerLot link you wouldn't have seen any /Point and you would have known why. Drop the /Point.

Maybe you didn't bother to read my explanation to you the last time you said this. I respect you and all the knowledge you bring to discussions here, but why is your function (including your DeltaPerlot) the only and exclusive way to calculate lotsizes? I have looked long and hard at your DeltaValuePerLot function. As I explained to you in a previous post (which I had hoped you had at least read), I wanted the value per point. And your DeltaValuePerLot did not give me value per point in deposit currency; that is why I don't use your DeltaValuePerLot. TickSize is a multiple of Point; this is why I must use Point to achieve a the appropriate divisor of TickValue. Sure, most (if not all) of the time, TickSize == Point and TickSize / Point == 1.0. But the rule is: TickSize is a multiple of Point. That is the reason I use Point the way I do in this instance. I wanted value per point in deposit currency; my PointValue calculation gives me that value. Now, hopefully, you know why I use Point!

We have no idea what SLoss is but it had better be a change in price, not pips or points.

We don't have much of an idea what SLoss is, but in my code (which the OP has modeled after), it sure better be distance in points! The general formula is: lotsize = risk amount / stoploss value. Since PointValue (as the self-describing name insists) is value per point in deposit currency, SLoss must in distance in points. The product of those two values create the stoploss value.

Look at the equation and your derivation again. Don't you want Risk_USD/ ( SLoss * PointValue ) or Risk_USD/SLoss / PointValue?

Risk_USD / (SLoss * PointValue). This was explicit in my code and inferred from my examples. Why would you divide by PointValue???

Risk = change in price * DeltaValuePerLot * lots. So If you want the change per point multiply by point. If you want the change in pips, multiply by pips like my link showed

The bigger the value per lot, the smaller the lots for the same risk.

Risk_USD / (SLoss * PointValue). This was explicit in my
code and inferred from my examples. Why would you divide by
PointValue???

Risk_USD / (SLoss * PointValue) is dividing by PointValue

Of course you MUST divide by PointValue. Your original post did NOT

double Lotsize = Risk_USD/SLoss*PointValue;

Thirteen: I trade in the US, so unfortunately, I am restricted by law and CFTC rule from trading precious metals in my forex account. Since I can't trade metals in my forex account, I generally don't code for them; and my code and functions reflect that fact!

FXCM is a US broker and allows metals Did you market watch -> right click -> show all?

and just because you can't (with your current broker) means you may not in the future (same or difference,) code it correctly and be done. Do you really want to have a known, waiting bug in your code?

WHRoeder:question:What is DIR?This version of the Traders Dynamic Index has the redrawing of the historical data eliminated, the algorithm calculation speed optimized, more external parameters for a more precise adjustments, and its functionalities extended: added the selection of the initial oscillator and the smoothing methods of the averages. Parameters Mode Osc - estimation oscillator selection; Period Osc - the calculation period of the oscillator used; Price Osc - applied price for the oscillation calculati

All traders using VSA realize the importance of the volume. Unfortunately, tick and spot volumes are not suitable for these purposes. I have conducted mathematical calculations and managed to trnsform the price into the volume that is close to the futures one by its ratios. Now, you do not have to wrestle with the question of where to obtain the volume data. Besides, you will be able to use the currency pairs having no futures at all. With RealVolume, you do not need to remember data on each ti

Does not support openning multiple orders on a single symbol on MT5 MultiMTCopier MT5Receiver - new and improved multi-terminal positions copier for your real/demo account, works faster, requires less, flexible in managing and upgrading, new information support. This Expert Advisor is designed for the MetaTrader 5 terminal, trades will be copied into this terminal. MultiMTCopier: The EA will copy all positions without delays Additionally integrated notification in situations requiring user

The script is intended for automatic placing of Buy Stop pending orders, Stop Losses and Take Profits on the user specified levels. Main Purposes: Avoiding unwanted entering a long position in case of false hitting the level as a result of widening of the spread by a dealing center. Avoiding unwanted triggering of a Stop Loss in case a quote pierces a significant level (fractal) without further confirmation with the close price. Setting a necessary virtual order and entering the market in

Parameters Three variables are available for every strategy, any one of them can be disabled, their period can be changed. type_order=ORDER_FILLING _FOK - order filling type. ReverseTrade=false — trades opens in reverse direction if true. ExitOnBar=true — trades close on each bar only. spreadcover=false — Spread you pay includes in profit trades. It's like trade with zero spread but you should remember that it can decrease exact match between tester's result and live one. It

Cluster analysis of volumes is now available in MetaTrader 5! The YuСlusters indicator is a professional tool for analyzing the trading volumes. The cluster graph is plotted based on tick data. For the exchange financial instruments these are the volume, type and price of a deal. For the Forex instruments - the real or tick volume (depending on the broker) and Bid price. There are 6 criteria of cluster generation: Time interval, the criterion is set in seconds. Price range, the criteri

Fast Copy MT5 allows you to copy trades between different MetaTrader 5 (netting)(hedge) and MetaTrader 4 accounts in any direction and amount, quickly and easily (without loading the system). Any type of copying is available MT4 → MT5 MT4 → MT4 MT5 → MT5 MT5 → MT4 * For the MetaTrader 4 terminal — Fast Copy MT4 * For the MetaTrader 5 terminal — Fast Copy MT5 ** Before the purchase, you can test the program by downloading the free demo versions — Fast

This is the Famous Timing Indicator You can now use the most famous Timing indicator on the planet. Millionaire Mostafa Belkhayate earned his reputation by using this specific indicator to validate the entry signals supplied by his also famous Center of Gravity indicator on the Forex market. I spent hours, days, weeks to decrypt the formula and now it is finally available to you. New and Unique for MetaTrader 5 Timing will give you perfect validations for your entry signals. It is the first

The script is intended for automatic placing of Sell Stop pending orders, Stop Losses and Take Profits on the user specified levels. This script is not that useful as "Virtual pending buy stop", since short positions are opened as Bid price crosses the levels. Thus spread widening is not dangerous. Nevertheless, you need to have this script to prevent unwanted hitting of the Stop Loss levels. Main Purposes: Automation of the process of placing the Sell Stop pending orders, Stop Losses and T

FULL Automatic is a fully autonomous trading robot for MetaТrader 5 without configurable parameters. It is similar to SAFE Automatic robot intended for traders having no knowledge of trading basics. It works in Low, Medium, High and Extremal trading modes. Trading strategy The EA applies modified versions of well-known strategies, including Elliott waves, following a trend, half-pyramiding, scalping, speculative trading with a double deposit protection. The EA switches the strategies automati

The indicator is designed for easy construction of synthetic charts based on data of various financial instruments. It will be useful both arbitrage and pair trading, as well as for analysis purposes. Its main advantage is simplicity and clarity. Each chart is given as a common mathematical formula. For example, if you want to plot the spread (difference) between EURUSD and GBPUSD with coefficients 4 and 3, then set the following formula: EURUSD * 4 - GBPUSD * 3 The resulting chart is shown in

The SetkaMT5 Expert Advisor is the MetaTrader 5 version of the Setka Expert Advisor which is designed for MetaTrader 4. This Expert Advisor has been written in MQL5 for the MetaTrader 5 Platform. Run the EA and it will create a grid of orders. Orders are created in both directions with a step that can be set in the EA properties. The number of limit and trend orders can also be set manually. Once the total profit reaches a predetermined value (you can specify it in the EA settings), all orders

The indicator is intended for determining the spread and swap size, the distance for setting stop orders and stop losses from the current price allowed and the risk per 1 point in the deposit currency. The indicator informs a trader about possible additional expenses and profits connected with transferring a position to the next trade session of the financial instrument. It also informs about the spread size and the distance of pending orders, stop loss and trailing from the current price. In a

Tick volume is equal to amount of ticks at the unit of time. There is direct correlation between tick volume and real amount of deals. Every change of the price is a result of a real request to perform a deal. Consequently, fewer requests we have, the less price changes we get, and, as a consequence, tick volume is smaller. In this case, when big amount of requests appear on the market, price changes happen more often. Big tick volume appears. Tick volume is an important indicator of trad

Percent Crosshair is a powerful and easy percentage measure tool. Measure the chart percentage very quick! Don't waste your time anymore! Just attach the Percent Crosshair indicator in the chart, select crosshair mode at toolbars or press "Ctrl+F" and start using the crosshair as you always do! The percent measure will be next to the indicative price. Customize your indicator the way you want! There are 4 entry parameters: Positive % color: set the desired color when % is positive. Negat

The indicator represents an additional chart window with a lower time frame where bars are combined into groups that are equivalent in time to main chart time frame. Bars are synchronized by the right hand side of the window, i.e. the time of the last bar in the main window corresponds to the time of the last bar group in the additional window. The maximum number of groups is 16; the maximum number of bars combined into groups in the additional window is 256. Limitations on the numbers are requi

Create your own list of trading instruments Watch list* and combine it with several open charts Link **. Using this program, a user can create fully-fledged Watch lists, create and delete trading instruments and move through the list. A selected symbol shows charts in linked windows. Linked windows can have different periods, indicators, experts, trading panels, etc... Moving through his/her Watch list, a trader an see the full image of his/her strategy in all windows. A lot of traders use 1

Reverse TradeCopier Follow can copy trades from an account that is running Reverse TradeCopier Source. Features: Copies trades from one source (master) account to multiple following (slave) accounts. Allows investor (read only) password for source (master) account. There are no complicated settings and input parameters, everything is easy. Works with different brokers. Works with different quotes symbols (EURUSD_FX, eurusd_m, etc.). Can copy orders from 4-digit quotes platform to 5-dig

Monitoring and Trend Analysis This product shows the trend strength levels based on 16 standard indicators, time periods and currency groups. Depending on the current trend, the indicator colors change from green to red, allowing you to see the full picture. Advantages Whatever your trading method and strategy are, you should always know, in which direction you are trading and what the probability of the trend change is. This indicator will help you answer these questions by calculating the

Market Profile defines a number of day types that can help the trader to determine market behaviour. A key feature is the Value Area, representing the range of price action where 70% of trading took place. Understanding the Value Area can give traders valuable insight into market direction and establish the higher odds trade. It is an excellent addition to any system you may be using. Blahtech Limited presents their Market Profile indicator for the MetaTrader community. Inspired by Jim Dalton’s

This is an utility for automatic scaling of a chart and making at least 140 bars visible in it. This is necessary for a correct wave analysis according to the Bill Williams' strategy "Trading Chaos". The utility can be used on any timeframe available in МetaТrader 5. It draws a vertical line through the first bar the calculation starts from. This line allows you to see the probable starting point of the wave sequence along with a sufficient number of bars displayed in the chart. It also makes t

Robust median Renko style indicator for creating custom charts resembling Median Renko, Mean Renko, Turbo Renko and Better Renko candles as well as vanilla Renko with wicks plus PointO charts. This all in one package provides all of the signals needed by day traders, scalpers and even long term traders. These include: The indicator is an overlay on the main chart so it is possible to utilize one-click trading and order manipulation directly on the custom charts. Visual order placement is a

This is an unusual (visual) representation of the famous WPR indicator. Instead of a separate subwindow, it is displayed in the main chart as a channel and levels. The next version of the indicator will have a possibility of smoothing its values using a moving average. Parameters PeriodWPR - calculation period of the percent price channel LevelUp - the value of the upper level in percentage (negative) LevelDn - the value of the lower level in percentage (negative) Center - the value of t

This indicator is based on Bollinger Bands indicator. It helps user clearly know the Band is expand or contract.

This indicator extracts a trend from a price series and forecasts its further development. Algorithm is based on modern technique of Singular Spectral Analysis (SSA). SSA is used for extracting the main components (trend, seasonal and wave fluctuations), smoothing and eliminating noise. Does not require the series to be stationary, as well as the information on presence of periodic components and their periods. It can be applied both to price series and to the data of other indicators. Implemen

How to use Pair Trading Station Pair Trading Station is recommended for H1 time frame and you can use it for any currency pairs. To generate buy and sell signal, follow few steps below to apply Pair Trading Station to your MetaTrader terminal. When you load Pair Trading Station on your chart, Pair Trading station will assess available historical data in your MetaTrader platforms for each currency pair. On your chart, the amount of historical data available will be displayed for each currency

This panel represents a demo account for binary options. It will catch an interest of those who start working with binary options and want to practice on a demo account. It will also spark an interest of those who use Meta Trader 5 to get signals for binary options. You can test any strategy using this panel. It supports any currencies available in your terminal. The panel is also very compact, and you can move it to any spot on your chart window. Now you do not need to look for a broker with a

This is an open interest indicator for MetaTrader 5. It fixes open interest value once per minute and writes it to the file (on your PC). The product works on any timeframe but only with exchange instruments.

Does not support openning multiple orders on a single symbol on MT5 MultiMTCopier MT5Source - new and improved multi-terminal positions copier for your real / demo account, works faster, requires less, flexible in managing and upgrading, new information support. This expert is designed for terminal MetaTrader5 from which the position will be copied. MultiMTCopier: The EA will copy all positions without delays Additionally integrated notification in situations requiring user attention Butt

The main purpose of the indicator is to detect and mark trade signals on the histogram of the Awesome Oscillator according to the strategies "Trading Chaos, second edition" and "New Trading Dimensions". The indicator detects and marks the following trade signals: "Two peaks" - Divergence. The signal "Second wise-man" - third consequent bar of the Awesome Oscillator after its color is changed. The histogram crosses the zero line. The signal "Saucer".The indicator includes a signal block th

If I am not wrong , the code in link you posted solves when you want to get lotsize from % of balance.

The code I linked to does illustrate position sizing using percentage of balance. But the main formula (lotsize = risk amount / stoploss value) is true for both percentage of balance and fixed risk amounts.

My question is, how can I improve the formula and make it finally usable? Should I multiply stoploss with PointValue like you do? Would that be a solution?

I can't answer your questions definitively because you haven't posted any of your code in which you attempt to "improve" the formula and "make it finally usable". This is partially why I gave you just the main formula (lotsize = risk amount / stoploss value). How you calculate both risk amount and stoploss value is up to you in your code (although, I caution you that calculating the stoploss value can be a bit tricky...and the subject of much debate on this site.). If you attempt to code it and encounter problems, post your attempted code here and several of us can try to help.

"although, I caution you that calculating the stoploss value can be a bit tricky...and the subject of much debate on this site."

Yes, plenty of opinions, topics and codes... That's why I asked for the solution, because I can't figure it out by myself. There's just too much of that everywhere and no solution. I didn't want to anyone to write an EA for me, I just wanted one function. What's wrong with that? If that's such a problem, sorry for bothering you.

I tried that:

Yes, plenty of opinions, topics and codes... That's why I asked for the solution, because I can't figure it out by myself. There's just too much of that everywhere and no solution.

I understand. There is allot of topics, conversations, and opinions regarding how to calculate lot size. There is no easy answer...there are times where you have to wade through the minutiae just to find the right answer.

I tried that:

Is your SLoss denominated in points or pips? To use PointValue, as I've used in my equation, stoploss must be distance denominated in points.

So, let's say that PointValue is 1.0 (standard account with USD deposit currency on a EUR/USD chart) and your stoploss is 1000 points (100 pips) and your fixed risk amount is $80.

The equation is: lotsize = 80 / (1000 * 1.0)

Therefore, lotsize = 0.08 (that is 8 microlots on a standard account).

That is why, using the code that I used in my equation, SLoss must be denominated in points, not pips. (If you used pips, rather than points, the equation would be: lotsize = 80 / (100 * 1.0), which is 0.80 (8 minilots) and a 10 times larger position then you wanted. However, you can change the equation to use pips...I just found it easier to use points.)

There is also a question of minimum and maximum lotsize and the lotstep. The minimum and maximum lotsize are self-explanatory...your lotsize must be equal to or greater than the minimum and must be less than or equal to the maximum. Lotstep determines the least significant digit for lotsize between the minimum and maximum. For example, if the minimum lotsize is 0.10 and lotstep is 0.01, then you can use lotsizes 0.10, 0.11, 0.12, etc, but not 0.09.

Review the code that I linked to to get an idea about minimum and maximum lotsize and lotstep.

question:"although, I caution you that calculating the stoploss value can be a bit tricky...and the subject of much debate on this site."

DeltaPerLotlink you wouldn't have seen any /Pointandyou would have known why. Drop the /Point. On currencies Ticksize == point but on metals they don't.SLossis but it had better be a change in price,not pips or points.Risk_USD/ ( SLoss * PointValue )orRisk_USD/SLoss / PointValue?On currencies Ticksize == point but on metals they don't.

I trade in the US, so unfortunately, I am restricted by law and CFTC rule from trading precious metals in my forex account. Since I can't trade metals in my forex account, I generally don't code for them; and my code and functions reflect that fact!

Had you bothered to look at my DeltaPerLot link you wouldn't have seen any /Point and you would have known why. Drop the /Point.

Maybe you didn't bother to read my explanation to you the last time you said this. I respect you and all the knowledge you bring to discussions here, but

whyis your function (including your DeltaPerlot) the only and exclusive way to calculate lotsizes? I have looked long and hard at your DeltaValuePerLot function. As I explained to you in a previous post (which I had hoped you had at least read), I wanted the value per point. And your DeltaValuePerLot did not give me value per point in deposit currency; that is why I don't use your DeltaValuePerLot. TickSize is a multiple of Point; this is why Imustuse Point to achieve a the appropriate divisor of TickValue. Sure, most (if not all) of the time, TickSize == Point and TickSize / Point == 1.0. But the rule is: TickSize is a multiple of Point. That is the reason I use Point the way I do in this instance. I wanted value per point in deposit currency; my PointValue calculation gives me that value. Now, hopefully, you knowwhyI use Point!We have no idea what SLoss is but it had better be a change in price, not pips or points.

We don't have much of an idea what SLoss is, but in my code (which the OP has modeled after),

it sure better be distance in points! The general formula is: lotsize = risk amount / stoploss value. Since PointValue (as the self-describing name insists) is value per point in deposit currency, SLoss must in distance in points. The product of those two values create the stoploss value.Look at the equation and your derivation again. Don't you want Risk_USD/ ( SLoss * PointValue ) or Risk_USD/SLoss / PointValue?

Risk_USD / (SLoss * PointValue). This was explicit in my code and inferred from my examples. Why would you divide by PointValue???

"Why would you divide by PointValue???"= OrderLotssmallerthe lots for the same risk.Risk_USD / (SLoss * PointValue). This was explicit in my code and inferred from my examples. Why would you divide by PointValue???is dividingby PointValueOf course you MUST divide by

PointValue. Your original post did NOTThirteen:I trade in the US, so unfortunately, I am restricted by law and CFTC rule from trading precious metals in my forex account. Since I can't trade metals in my forex account, I generally don't code for them; and my code and functions reflect that fact!known, waiting bug in your code?