Sorry, I mean ticks for the whole second duration (+/-1 sec) around the time the position was closed. because I suspect the terminal has some synchronization (timing) issues.
Sorry, I mean ticks for the whole second duration (+/-1 sec) around the time the position was closed. because I suspect the terminal has some synchronization (timing) issues.
No. Please check the link to the original post to get all information ;-)
The bid and ask were known and the bid was 1.44725. I checked the history, this trade was close exactly at 2022.08.28 23:05:00.871 and at that time here are the ticks :
The loss is clearly calculated using 1/Ask, not 1/Bid.
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
Ok, this is a proof based on numbers from the terminal (not theories).
I ran the test on two different terminal, one with an account currency = EUR, the other's account currency is USD.
First I use a script, to open positions on all forex symbols on the market watch using a large position size as possible. I increased the demo balance to the maximum 100K to do the tests.
Then, I used a second script "2. AnalyzePositionProfits_Script.mq5" to analyze profits of all open positions, using these methods:
POSITION_PROFIT field
OrderCalcProfit() function
SYMBOL_TRADE_TICK_VALUE_xxxx
Conversions from profit currency -> account currency
As can be seen POSITION_PROFIT is sometimes (but not always) equal to profit calculation using OrderCalcProfit(). The reason for this may be a timing (sync) issue between the ticks on the server used to calculate the POSITION_PROFIT field and the later ticks reaching the terminal. So, my conclusion is that the value of the POSITION_PROFIT field is calculated on the server, independent of the quote data arriving to the terminal in that exact moment.
All the other methods are matching my previous calculations:
SYMBOL_TRADE_TICK_VALUE_LOSS is used to calculate profit of BUY orders.
SYMBOL_TRADE_TICK_VALUE_PROFIT is used to calculate profit of SELL orders.
No correlation between the TICK_VALUE_xxxx names (PROFIT/LOSS) and the price type (BID/ASK) of profit/account currency conversion rate.
The price type (BID/ASK) of the profit/account conversion pair depends to two things: (a) the type of the order (b) position of account currency in the pair (first or second).
It was better if the names wereSYMBOL_TRADE_TICK_VALUE_BUY (for SYMBOL_TRADE_TICK_VALUE_LOSS) and SYMBOL_TRADE_TICK_VALUE_SELL (for SYMBOL_TRADE_TICK_VALUE_PROFIT)
Maybe they convert the AUD loss to GBP first and then they convert from GBP to EUR... I'm not sure but I read something like that once, I'm going to try to read something on this topic tonight to double check
My trading account is in USD, so say I want to go short GBP/JPY. Wouldn’t I have to first go short USD and long GBP? And if so, wouldn’t it be like I was in two trades at once and wouldn’t I be affected by changes in both GBP/USD and GBP/JPY?
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
I am also having no explanation for your trade @Alain Verleyen. I told you before it is contradictory to my previous tests.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I already provide these data in the topic, not ?
Sorry, I mean ticks for the whole second duration (+/-1 sec) around the time the position was closed. because I suspect the terminal has some synchronization (timing) issues.
Sorry, I mean ticks for the whole second duration (+/-1 sec) around the time the position was closed. because I suspect the terminal has some synchronization (timing) issues.
I already posted it. You want more ?
Forum on trading, automated trading systems and testing trading strategies
SYMBOL_TRADE_TICK_VALUE_LOSS vs SYMBOL_TRADE_TICK_VALUE_PROFIT
Alain Verleyen, 2023.02.21 20:54
No. Please check the link to the original post to get all information ;-)
The bid and ask were known and the bid was 1.44725. I checked the history, this trade was close exactly at 2022.08.28 23:05:00.871 and at that time here are the ticks :
The loss is clearly calculated using 1/Ask, not 1/Bid.
I already posted it. You want more ?
I already posted it. You want more ?
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
Wait few minutes. I am posting the results of the test I ran it.
See it and then decide.
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
Yeah...I can't figure it out either.
Forum on trading, automated trading systems and testing trading strategies
Serious bug in the OrderCalcProfit() function
amrali, 2023.02.21 23:35
Ok, this is a proof based on numbers from the terminal (not theories).
I ran the test on two different terminal, one with an account currency = EUR, the other's account currency is USD.
First I use a script, to open positions on all forex symbols on the market watch using a large position size as possible. I increased the demo balance to the maximum 100K to do the tests.
Then, I used a second script "2. AnalyzePositionProfits_Script.mq5" to analyze profits of all open positions, using these methods:
The script outputs the results to csv file. I always use Ron's CSV editor to read csv files. https://www.ronsplace.ca/Products/RonsEditor/Download
Here is the result from the EUR account:
Here is the result from the USD account:
As can be seen POSITION_PROFIT is sometimes (but not always) equal to profit calculation using OrderCalcProfit(). The reason for this may be a timing (sync) issue between the ticks on the server used to calculate the POSITION_PROFIT field and the later ticks reaching the terminal. So, my conclusion is that the value of the POSITION_PROFIT field is calculated on the server, independent of the quote data arriving to the terminal in that exact moment.
All the other methods are matching my previous calculations:
Yeah...I can't figure it out either.
Maybe they convert the AUD loss to GBP first and then they convert from GBP to EUR... I'm not sure but I read something like that once, I'm going to try to read something on this topic tonight to double check
This is really frustrating Alain, not gonna lie, I'm still trying to figure out what is happening in this example and I don't understand why it would use the ask to convert the loss, this make no sense... I'm still trying to understand though...
I am also having no explanation for your trade @Alain Verleyen. I told you before it is contradictory to my previous tests.
I am also having no explanation for your trade @Alain Verleyen. I told you before it is contradictory to my previous tests.
I will check your results and investigate further on my side.
Will post my feedback...not sure when though.