How to calculate buy volume based on balance and stock price ?
-
I´m writing a EA that will work on stocks (not forex/pips) and suppose I want to buy/sell 100% of balance
In the MT5 strategy test I set a initial deposit of 100.000 (BRL).
Suppose the stock is at 19.20 price. So the first trade (buy)
100.000 / 19.20 = 5208,33I have to buy/sell multiple of 100, so it would be 5200.
How can I code this in the BUY option to match this exact volume dynamically ?
Thanks
-
I think you Will have to use a "Custom MQL Code" block with the next math function
-
But even ignoring the way to round the number, is there any BUY option that will give me the 100.000 / 19.20 = 5208,33 ? Tried many options but found none, seems to me that every option is designed for forex, always ignoring the price of the stock. Or am I missing something?
-
anyone ?
-
