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 ... };
Thanks a lot. I managed to figure out and uses OrderCalcProfit instead
- www.mql5.com
Hi
I've tried using OrdercalcProfit but it seems that the first order is always giving me 0.01 lotsize
Subsequent trades on other pairs are behaving normally
Eg. Today, my first trade is on EURAUD and is 0.01, other pairs all ok
Fyi. My deposit currency is SGD
Does OrdercalcProfit needs to sync with some SGD pairs first?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My balance is 1950 SGD.
My EA opened some trades on EURGBP today and the lotsize is 0.01 and the next trade is 0.13.
Any idea what happened?
During backtesting, I did not encounter this issue at all.