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
this is the test I made with the OrderCalcProfit( ...)
while the resulting dbOrderLots = 1791.90 the force to 100.0 = dbLotsMax
so the correct value is 1791.90 and is more or less equ to the value of my previous post.
Ok , I can use this formula or my previous formula. it's pretty the same.
but I was thinking about the case of opening a BUY order with riskMax = 5000 with the mentioned prices...
If I well undestand with a the broker limit of LotSize = SymbolInfoDouble("XAUUSD", SYMBOL_TRADE_CONTRACT_SIZE); = 10 and the lotsize of 1791.9 limited to 100.0
signifies that I have to put 17 x 100.0 = dbLotsMax orders ?? or better
16 x 100.0 = dbLotsMax orders +
1 x 91.9 order ??
could you clarify me this
thanks
No, you have another volume limit in the contract specifications that you have to abide by, namely SYMBOL_VOLUME_LIMIT, which will not allow you to overstep things so easily.
SYMBOL_VOLUME_LIMIT
Maximum allowed aggregate volume of an open position and pending orders in one direction (buy or sell) for the symbol. For example, with the limitation of 5 lots, you can have an open buy position with the volume of 5 lots and place a pending order Sell Limit with the volume of 5 lots. But in this case you cannot place a Buy Limit pending order (since the total volume in one direction will exceed the limitation) or place Sell Limit with the volume more than 5 lots.
double
It is advisable to use OrderCalcProfit() instead of tick_size to calculate the required position size:
* (1) avoid wrong tick_values for non-forex symbols (e.g., gold) by some brokers.* (2) apply the correct profit calculation method depending on SYMBOL_TRADE_CALC_MODE,
* (3) adjust the tick_value to future rate (SL) if the base currency == account currency.
please check the full code at https://www.mql5.com/en/code/viewcode/28029/267359/functions.mqh
Edit:
if your broker provides correct tick values, and you want to use them to calculate the position size, then please note that:
SYMBOL_TRADE_TICK_VALUE_PROFIT is used to calculate position size of SELL (short) orders.
SYMBOL_TRADE_TICK_VALUE_LOSS is used to calculate position size of BUY (long) orders.
Hi guys :
@Fernando Carreiro : thanks , so I can suspect that all that limitations is because i have a demo account, Ok i'll take it in to account.
@amrali thank you for your suggestions. I have just tested this function with the code at the init of the page. Now I apply this line that seem more clear
your line : volume=risk_money/(MathAbs(profit/maxvol)+2*commission_lot);
last question outside of these considerations.
If I want to use the EA in MAC notebook what is better todo :
1. can I use the compiled code in window also for MAC
2. do I have to recompile the code using metaeditor for MAC
3. is better use the compiled code in window and use it with Wine for MAC or use Parallel
what you suggest about ?
Thank a lot to all guys
Some broker have wrong tick value but profit is true.
try use the function, I also get it from forum
I just want to thank you.
I got an incorrect tick value in XAUUSD when trying to get lot size per risk, i got 10 instead of 1, with that function I was able to get correct values, works like a charm.
Here is my final code case anyone want:
Wouldn't OrderCheck() return you the values you need in the struct MqlTradeCheckResult:
Field
Description
retcode
Return code
balance
Balance value that will be after the execution of the trade operation
equity
Equity value that will be after the execution of the trade operation
profit
Value of the floating profit that will be after the execution of the trade operation
margin
Margin required for the trade operation
margin_free
Free margin that will be left after the execution of the trade operation
margin_level
Margin level that will be set after the execution of the trade operation
comment
Comment to the reply code, error description