Calculating the cost of 1 lot, for any pair / digits / decimals / broker
I posted up the fully-automated code for this a while back, see my posts and links throughout the following thread: https://www.mql5.com/en/forum/129553
Works for any currency pair, regardless of 4D/5D, and is broker agnostic, etc. Haven't found a broker that it does not work for but I'm sure there are some.
How to calculate the cost in dollars of entering with 1 lot at given price ( EntryPrice ) with given StopLoss price ( SLprice ) ?
The (more or less) above seems to work ok for eg. EURUSD, but not for the more special pairs like Silver... for Silver I get a cost that is approx 1/5 of what it should be... so I enter with 5 times the intended lots !
It obviously has to do with PointSize, TickSize, TickValue, Points, and Digits .
There must be a "fully automatic" way to get this right for any digits, decimals, and 4 or 5 digit brokers. But I can't get my head around this.
Any suggestions ?
Here are MarketInfos that I extracted for some pairs: