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
Fernando Carreiro #:
EDIT: This is why I believed the discussion was fruitless, because wanting to get so much precision, just to have it slashed by rounding it to the volume precision, seemed to me only valuable academically, but not in practice.
However, what may be fruitless to me, may be of great importance to others, so maybe I should have explained this early on instead of now.
Some people might risk €10 per trade, others 10,000 €. It's only making a difference if you trade approximately 2 lots or more. Thanks again for the clarifications, I'm sure it can be very useful for anyone trying to decide if they should consider these adjustments for their EA's.
Did you try it on a live market, a symbols which are not using the account currency ? It's very hard to have exact values because MT5 is by nature asynchronous, it can happens and it effectively happens that the needed quote (or tickvalue) is changed between the time your get POSITION_PROFIT and the time you calculate the profit. Anyway, it doesn't really matter.
I agree and that's why I wrote code that allows me to visually inspect the results for one position at a time as it changes with each tick. I think this might reduce the impact of what you're describing (maybe not) but for very small differences that are approximately the size of the spread (very close to exact values), like in Amrali's data, it won't make a difference in your lot size I think so in the end, you're right, it won't matter. Fernando and myself were discussing the impacts on lot size caused by a change of rate on a pair when your account currency is the base currency and these variations are much larger than the ones you and Amrali see in your data.
Your correction doesn't make sense on an open position.
For a BUY, Bid = current price (close_price). For a SELL, Ask = current price (close_price). Your correction do nothing. It only makes sense when the close price is the future closure price.
Yes, you are 100% correct. I did this on purpose but I should have specified this to avoid confusion. I tested this with a future closing price before and got the same results. You just have to replace the position's current price in the code with a future closing price you get from an input setting or from a position's stop loss and keep the rest of the code the same. I tested all versions and in the end I finished with this one which I coded very quickly while doing something else just to see if the profit calculations with OrderCalcProfit and manual conversions also matched the terminal profit like the risk size calculations did in my previous tests. I was hoping to verify Amrali's results for profit calculation while trying to use a different approach. To be honest, I sensed that some of you were getting tired of this thread so I wasn't putting as much effort in the code as I usually do and I also made a few errors that ended up compiling and working anyways since the values are both equal so I didn't bother to change them (ex: ORDER_TYPE_BUY vs POSITION_TYPE_BUY). I hope this didn't cause too much confusion.
I used the €10 example, only because I wanted something to illustrate the point with a volume of 0.01 (minimum and step values, precision) to illustrate the point, not because I believe traders only risk that amount.
I know! :)
Anyways, someone doing this casually could risk €10, there would be nothing wrong with that, and your example would apply to them so it was still worth mentioning...
SYMBOL_TRADE_TICK_VALUE = SYMBOL_TRADE_TICK_VALUE_PROFIT = SYMBOL_TRADE_TICK_VALUE_LOSS
= [1 / (10 ^number of digit after the decimal point)] * standard contract size (of 1 lot)
example: EURUSD: number of digit after decimal point = 5, standard contract size (of 1 lot) is 100000 units.
=> SYMBOL_TRADE_TICK_VALUE = [1 / (10^5)] * 100000 = 1 (USD, because USD is behind EUR in the symbol EURUSD)
SYMBOL_TRADE_TICK_VALUE = SYMBOL_TRADE_TICK_VALUE_PROFIT = SYMBOL_TRADE_TICK_VALUE_LOSS
= [1 / (10 ^number of digit after the decimal point)] * standard contract size (of 1 lot)
example: EURUSD: number of digit after decimal point = 5, standard contract size (of 1 lot) is 100000 units.
=> SYMBOL_TRADE_TICK_VALUE = [1 / (10^5)] * 100000 = 1 (USD, because USD is behind EUR in the symbol EURUSD)