Improperly formatted code edited by moderator. Please always use the CODE button (Alt-S) when inserting code.
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Consider using OrderCalcProfit instead.
Forum on trading, automated trading systems and testing trading strategies
SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE) sometimes zero
Fernando Carreiro, 2022.08.23 17:41
You can! These are the steps I take. I supply the function with a lot size equal to the “Max Lot Size” allowed for the symbol in question, then calculate the ratio needed to achieve the fractional risk that I wish to apply, to get the correct volume for the order. I then align that with the “Lot Step” and finally check it against both the maximum and minimum allowed lots for the symbol.
The reason I use the “maximum” lots instead of just “1.0” lots as a reference value is because there is no guarantee that the value of 1.0 is within the minimum and maximum values allowed. Given that using 1.0, or the maximum, gives equivalent results anyway (by using the ratio method), I choose to use the “max lots” as the reference point which also offers the most precision for the calculation.
Something like this ...
// This code will not compile. It is only a example reference if( OrderCalcProfit( eOrderType, _Symbol, dbLotsMax, dbPriceOpen, dbPriceStopLoss, dbProfit ) ) { dbOrderLots = fmin( fmax( round( dbRiskMax * dbLotsMax / ( -dbProfit * dbLotsStep ) ) * dbLotsStep, dbLotsMin ), dbLotsMax ); // the rest of the code ... };
![[Help - fixed] Leverage is disturbing my Size calculation. Using TV. [Help - fixed] Leverage is disturbing my Size calculation. Using TV.](https://c.mql5.com/36/79/help-fixed-leverage-is-disturbing.jpg)
- 2023.06.23
- www.mql5.com
No I use the same symbol on strategy tester platform but the code claculate different volume size for trades that SL and entry points are all the same.
I have attached above my code.
Yes, you have provide the code, but you have not provided anything else.
- Is it the same broker and trading account?
- Is it the same account currency selected in the Strategy Tester?
- Are the contract specifications for the symbol the same in each case?
- etc.
Have your code print out the relevant information to the log file and show us the results for the tests on different computers ...
- Tick Size
- Tick Value
- Account Balance
- Account Currency
- Entry price
- Stop Size
- Risk percentage
- etc.
Hello, thanks for your prompt replies.
I found out the issue.
In one PC metatrader calculated the trade commissions but in another one no. it seems metatrader for different brokers calculate commissions and others not in strategy tester.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am coding an expert and for volume calculation using below function.
but regret volume in different computers differs. one will be 1.38 and the other one is 1.39000000001.
What is my problem and how can fix it ?