You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Well, this may be controversial and there will be users contesting what I state, but in my opinion MetaQuotes has made a mess of it and it should not be about loss or profit, but about current ask and bid prices. These two “tick values” should be renamed as “ask”/“bid” tick values and not “profit”/“loss” which would also require knowing the direction of the trade.
The “correct” risk calculation being promoted on the forum by the more experienced users, including myself, is technically wrong (and that includes my code). This is because we calculate the risk based on some assumptions which are technically incorrect. I accept this “calculation error” because I understand what is wrong with it and know that I am only working with an approximation of the risk value, even though it can often be slightly off.
The fundamental assumption is that the tick value at the stop-loss price (or the take-profit price) will remain the same compared to the opening price, which is often not the case. Unless you are trading “xxx/USD” currency pairs (or the like) with a deposit account currency of USD, then the tick value will change with the quote price, both bid and ask prices.
If one really wants to create a technically correct and precise calculation of a risk or a reward, one would need to code a custom function that does all the cross currency calculations to get the tick value at the closing price at the stopless (or take profit) and in reference to the tick value at the opening (considering ask or bid prices and direction of the trade).
This, however, can be a considerable task and not worth it when the approximate value of the risk (or the reward) suffices for calculating the volume of an order, which is very granular anyway.
If one really wants to improve the current method of risk calculation, one could take the average of the two tick values (“profit” and “loss”) and use that instead, or use one or the depending on if it is a buy or sell position, but the difference would be minor.
Hi Farnando,
I am not sure if it is okay for me to post here because this is my first post on this forum. I have a problem the i need to solve but I could not figure out how to do that.
1. I have Open Price e.g. 1704.00 for XAU/USD
2. I have Stop Loss Price e.g. 1688.00 XAU/USD
3. I want to open 10 trades at 150 points interval from open price to stop loss price
4. i want to risk 0.5% of account balance for all 10 Trades
5. I want to calculate lot size for each trade
So, I wrote the following code and I am getting lot size 0.14 per trade, but my total loss is:-1137.5, where as it should be -125.
1. I have Open Price e.g. 1704.00 for XAU/USD
2. I have Stop Loss Price e.g. 1688.00 XAU/USD
3. I want to open 10 trades at 150 points interval from open price to stop loss price
4. i want to risk 0.5% of account balance for all 10 Trades
5. I want to calculate lot size for each trade
So, I wrote the following code and I am getting lot size 0.14 per trade, but my total loss is:-1137.5, where as it should be -125.
Assuming that each point is worth $1.00 for 1 Lot, then for 0.14 lots, 1 point is worth $0.14.
1. I have Open Price e.g. 1704.00 for XAU/USD
2. I have Stop Loss Price e.g. 1688.00 XAU/USD
3. I want to open 10 trades at 150 points interval from open price to stop loss price
4. i want to risk 0.5% of account balance for all 10 Trades
5. I want to calculate lot size for each trade
So, I wrote the following code and I am getting lot size 0.14 per trade, but my total loss is:-1137.5, where as it should be -125.
Thank you for your response. It did help me narrow down the issue.
I guess I got it right in the following way:
with the following code, I am getting total volume from formula Risk = (netClosingPrice - netOpeningPrice )/totalVolume. Therefore, totalVolume must be divided by totalPostions to get the lotSize for individual trades:
double totalVolume = riskAmount/ (pipDistanceToSlPriceFromAverageOpenPrice*DeltaValuePerLot());
double lotSize = NormalizeDouble(totalVolume/ totalPositions, _Digits);