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
I just realized my mistake: in the example where your account is in USD, if you open a 1 lot position on USDCAD at 1.35000 and close it at a loss at 1.34999, the move is 1 tick, but the value of that move is NOT the tick value at 1.35000 (1 / 1.35000 = 0.7407407...), the correct value for that move is the tick value at 1.34999 (1/1.34999 = 0.7407462...).
Now I feel like an idiot for using SYMBOL_TRADE_TICK_VALUE_LOSS or SYMBOL_TRADE_TICK_VALUE_PROFIT to calculate the correct lot size before I open a position, feel free to laugh, but I hadn't realized that this would make a difference... it didn't really make a difference on small accounts because the lot size would usually still be correct, but on large accounts with large lot sizes, it starts to make a difference.
So, I use OrderCalcProfit() to calculate the expected loss at the (future) exit price. This only applies for Forex symbols where the base currency == account currency, which calculates a correct loss. It applies the necessary adjustment for the tick value, and profit/loss.
You are both wrong. The tick value is independent of the direction of a trade (BUY or SELL).
The market is closed, so I can't prove it with data for now.
But let see some theory in the first place :
What is a tick ? It's the smallest price movement for a considered symbol. Let's take EURUSD, with a 5 digits standard quotation, so a tick is 0.00001 (tick size).
What is a tick value ? is the value, in account currency, of this minimal price movement (tick or tick size), considering a traded volume of 1 lot (let's say a standard lot so 100,000 units).
How do we calculate the value of a tick ?
Let's take some examples.
Account in EUR. All trades will require a conversion because no symbol is using EUR as profit (loss) currency.
So with an EUR account, SYMBOL_TRADE_TICK_VALUE_PROFIT is always the ASK price of the conversion symbol needed, which may or may not be the traded symbol. And SYMBOL_TRADE_TICK_VALUE_LOSS is always the bid price of the conversion symbol.
Account USD. Here, we have more possibilities.
Symbols with USD as the profit (loss) currency will not need conversion. Symbols with direct conversion will have SYMBOL_TRADE_TICK_VALUE_PROFIT matching bid conversion price, and SYMBOL_TRADE_TICK_VALUE_LOSS will match the ask conversion price. In reverse, for symbols with "indirect" conversion, SYMBOL_TRADE_TICK_VALUE_PROFIT matching ask conversion price, and SYMBOL_TRADE_TICK_VALUE_LOSS will match the bid conversion price.
Account JPY.
I will not give the details, the logic is the same.
There is never a conversion needed when JPY is implied, as JPY is always the profit/loss currency.
When a conversion is needed the conversion is always "direct" as JPY is always the second part of a symbol, so on an JPY account, SYMBOL_TRADE_TICK_VALUE_PROFIT is always the BID price of the conversion symbol needed, which is never the traded symbol. And SYMBOL_TRADE_TICK_VALUE_LOSS is always the ask price of the conversion symbol.
There are some specific cases, mainly when the trading is in a more "exotic" currency, like for example SGD (Singapour dollar) where it happens the crosses pairs needed for conversion is not available. Say a CADCHF trade, which would require a SGDCHF symbol to convert in CHF profit/loss in SGD, but this SGDCHF pair is not available, in such case, there will be a double conversion using USD. So from CHF to USD using USDCHF, then from USD to SGD using USDSGD.
Alain was right, it's not about a short or a long, it's only about profits vs losses.
After all my tests, I found that the simplest way to think about this is that you want to find the exchange rate between the symbol's quote currency and your account's currency and perform the conversion calculation with either the ask or the bid in order to make it so that you always end up with the worse deal (since you pay a spread on the final conversion, you'll always end up with less profits or more losses). If you think about it this way, you'll realize that it's not about the order type but only about if the position ends up in a profit or loss and if the exchange rate shows your account currency as the quote currency or the base currency. And that's because the way you convert a loss to your account currency isn't the same as how you convert to profits. With a loss, you have to sell your account currency to cover the loss. But with a profit, you have to sell your profits in exchange for your account currency (which is the same as saying you want to buy your account currency).
Convert CAD profits to USD: divide by USD/CAD ask (profit + account currency is the base currency in the conversion rate = use the ask)
Convert CAD losses to USD: divide by USD/CAD bid (losses + account currency is the base currency in the conversion rate = use the bid)
Convert GBP profits to USD: multiply by GBP/USD bid (profit + account currency is the quote currency in the conversion rate = use the bid)
Convert GBP losses to USD: multiply by GBP/USD ask (losses + account currency is the quote currency in the conversion rate = use the ask)
But Amrali and Fernando are also correct when they say it's only an approximation if you use SYMBOL_TRADE_TICK_VALUE_PROFIT or SYMBOL_TRADE_TICK_VALUE_LOSS because you need to know the conversion rate when the position will close so I'm just going to write code to calculate everything manually. But when my account currency isn't in the traded pair then there's no way of knowing the final conversion rate so in that case it will always be an approximation even if you calculate it manually.
So the difficulty in calculating the tick value isn't with knowing the value of the profits in the quote currency, but with converting them correctly to our account's currency, which is done either with the ask or the bid of that final conversion rate depending on if our account currency is the quote currency or the base currency in that exchange rate and if we are converting a loss or a profit.
Am I wrong?
I just want to add that it's easy to manually calculate the exact tick value but it's not useful because if you're trying to calculate the value of a loss to calculate your position size then, unless your account currency is the pair's quote currency, the amount lost for each tick in the move will always depend on what price the position is closed at. So you don't need the tick value to find the answers, you just need to know the size of the move and the exchange rate between the pair's quote currency and your account's currency at the time of closing the trade. For example, with USDCAD, if you short and the price moves up by 1000 ticks. What you'll need is the closing price, for example lets say the closing price would be 1.31000, and you know that for 1 lot you lose 1 CAD per tick, so you lose 1000 CAD on this move. But now you need to convert it to USD if your account currency is USD and you need to do this with the bid in this case because the account currency is the quote currency in USD/CAD so you take the closing profit in CAD which is -1000$ CAD and you divide it by the closing bid so -1000$ / 1.31000 and you get 763.36$ USD lost for a 1 lot position on USDCAD if a 1000 tick move closed at 1.31000 on USDCAD with USD as the account currency. But you see in this calculation I never calculated the tick value, there simply isn't any reason to do so. If you're account currency is in the pair you are trading, either as the quote currency or the base currency, then you can get an exact answer when calculating the value of a loss for 1 lot in your account currency. But if you were doing this with a pair that didn't contain your account currency, you should probably use whatever exchange rate is currently available for your final conversion even if you know it will likely change before the position reaches its stop. In this case you can only estimate the value of a loss for 1 lot because what you'll calculate is the value of a loss IF the exchange rate between the pair's quote currency and your account currency will be the same when you close your position. Since in this case it doesn't matter what the final conversion rate will be because there is no way you can know what it will be in the future (to convert profits to your account currency), in this case, and only in this case, but it's not really going to be faster to code than doing the conversion with the exchange rate instead of the tick value.
Give me any example including traded pair, closing price, size of the move in ticks, if it's a loss or a profit, and the exchange rate (ask or bid) between the quote currency and the account currency at the time of the close or at the time the position is open if the future value can't be known and from that I can tell you the value of a loss or profit for a 1 lot position on that pair, on any pair you want and I can tell you the value of a loss or profit in your account currency without ever asking you if it's a short or a long and without ever calculating the tick value and I should be able to give you an exact answer when possible or best approximation if future conversion rates can't be known in advance.
Alain was right, it's not about a short or a long, it's only about profits vs losses.
After all my tests, I found that the simplest way to think about this is that you want to find the exchange rate between the symbol's quote currency and your account's currency and perform the conversion calculation with either the ask or the bid in order to make it so that you always end up with the worse deal (since you pay a spread on the final conversion, you'll always end up with less profits or more losses). If you think about it this way, you'll realize that it's not about the order type but only about if the position ends up in a profit or loss and if the exchange rate shows your account currency as the quote currency or the base currency. And that's because the way you convert a loss to your account currency isn't the same as how you convert to profits. With a loss, you have to sell your account currency to cover the loss. But with a profit, you have to sell your profits in exchange for your account currency (which is the same as saying you want to buy your account currency).
Convert CAD profits to USD: divide by USD/CAD ask (profit + account currency is the base currency in the conversion rate = use the ask)
Convert CAD losses to USD: divide by USD/CAD bid (losses + account currency is the base currency in the conversion rate = use the bid)
I was used to think like that but :
Forum on trading, automated trading systems and testing trading strategies
Serious bug in the OrderCalcProfit() function
Alain Verleyen, 2023.02.19 23:21
The problem is the profit/loss of this trade was -227.59 EUR.
So the real calculation was :
double profit = volume*contract*(close-open)*GetExchangeRate("AUD","EUR",BUY); /*Rate = 1/Ask*/
= 0.07*100,000*(1.70407-1.75114)*(1/1.44774);
= -227.59 EUR
This is a trade from a real account.
So now I am a bit confused (and you will probably be too after reading this, sorry ). When I have time I will check in depth.
Convert GBP profits to USD: multiply by GBP/USD bid (profit + account currency is the quote currency in the conversion rate = use the bid)
Convert GBP losses to USD: multiply by GBP/USD ask (losses + account currency is the quote currency in the conversion rate = use the ask)
But Amrali and Fernando are also correct when they say it's only an approximation if you use SYMBOL_TRADE_TICK_VALUE_PROFIT or SYMBOL_TRADE_TICK_VALUE_LOSS because you need to know the conversion rate when the position will close so I'm just going to write code to calculate everything manually. But when my account currency isn't in the traded pair then there's no way of knowing the final conversion rate so in that case it will always be an approximation even if you calculate it manually.
So the difficulty in calculating the tick value isn't with knowing the value of the profits in the quote currency, but with converting them correctly to our account's currency, which is done either with the ask or the bid of that final conversion rate depending on if our account currency is the quote currency or the base currency in that exchange rate and if we are converting a loss or a profit.
Am I wrong?
It's an approximation whatever you will use. Because, as you rightly said, you need the values when the position is closed, which is unknown obviously (except when no conversion is needed or when you only need the "theoretical" close price of the traded symbol).
I was used to think like that but :
So now I am a bit confused (and you will probably be too after reading this, sorry ). When I have time I will check in depth.
It's an approximation whatever you will use. Because, as you rightly said, you need the values when the position is closed, which is unknown obviously (except when no conversion is needed or when you only need the "theoretical" close price of the traded symbol).
1.75114 to 1.70407
size of move on GBPAUD 0.04707
1 lot = 1 AUD per tick (with contract of 100,000 units)
so 1 lot = 4707 AUD
for 0.07 lots = 4707 * 0.07 = 329.49 AUD
so the loss for this trade (excluding swaps) is exactly 329.49 AUD
but now when the position is closed it will convert this loss to your account currency
in this case the EURAUD conversion will use EURAUD's bid to charge you a second spread
so 329.49 AUD / EURAUD bid price at time of close = loss in EUR
so 329.49 / X = loss
but in your example we don't know the EURAUD bid price at the time of the close, but we can isolate X to find out
X = 329.49 / loss
X = 329.49 / 227.59 (assuming this doesn't include the swap)
X = 1.44773496....
X = 1.44773
So at the time this position closed, the EURAUD bid should have been exactly 1.44773
This seems to match what I see for the 8/28/2022 on EURAUD by the way
So in conclusion, you think it divided by the ASK, and come up with 1.44774 as the ask for EURAUD, but I'm coming up with 1.44773 with the calculations I just did, so maybe the ASK was 1.44774 but my math shows me the price used for the conversion was 1.44773 which would confirm it was converted with the bid, not the ask.
How do you arrive at 1.44774 instead of 1.44773? and how do you conclude that that was the ask instead of the bid?
By the way no matter if you divide by 1.44773 or 1.44774 you still get 227.59 when you round your answer. But again, the only way you will prove that the way I'm calculating is correct is if you can find out exactly what the bid and ask was on EURAUD when the position closed. And you'll need an example with a larger position size so that the loss size isn't the same if you calculate the conversion with the bid or ask. (if the bid was 1.44773 and the ask was 1.44774, then you can't prove anything with your trade because no matter what you choose for the conversion you still get the same loss amount).
My calculations tell me that if we assume the BID was used for the conversion (which is the logical conclusion when you do the conversion from AUD to EUR using the EURAUD exchange rate and know that you'll be charged a second swap on the conversion) and the BID should have been 1.44773, but since we don't know, there is no way to confirm this. But remember how I explain the logic in simple terms, if you convert AUD to EUR using the ask on EURAUD, you're getting a smaller loss than if you convert it with the bid, which doesn't make any sense because you always should pay a spread when converting to a different currency.
Regardless, in an example like this, you CAN'T use this math to predict the loss when opening the trade, because you don't know what the EURAUD bid will be when you will close the trade. In this case you would use the current bid on EURAUD and hope it doesn't change too much before the position closes. This will allow you to calculate the best approximation for the position size you want.
But in any case where EUR would have been either the quote or base currency in the traded pair, I'm confident I would have been able to calculate the exact loss at the future closing price using the logic and math I outlined here and in my previous thread. (I'm now convinced you are the only one that was correct when you said that the order type doesn't matter and that to know if the conversion is done with the BID or ASK you just have to know if it's a loss or a profit and where your account currency is (quote or base) in the conversion exchange rate.
*edit: in summary, I think your confusion with that example comes from the fact that the position uses only 0.07 lots, so no matter if you divide by 1.44773 or 1.44774 in the final conversion, you still get the same loss of -227.59 EUR after you round to the nearest 0.01 EUR. I'm pretty sure that you would see there is no confusion if the position had been larger. But if you simply ask yourself "in this example, should I divide by the EURAUD bid or the EURAUD ask in order to pay a spread on the conversion", you'll see that the only logical answer is to divide by the bid for a loss or the ask for a profit (because EUR is the base currency in the final conversion rate).
It's an approximation whatever you will use. Because, as you rightly said, you need the values when the position is closed, which is unknown obviously (except when no conversion is needed or when you only need the "theoretical" close price of the traded symbol).
Yes, exactly, so if your account currency is EUR, you can predict the exact loss value on pairs like EURUSD, EURCAD, EURGBP, etc but can't predict the exact loss on pairs like USDCAD, USDCHF, etc...
If your account currency is USD, you can predict the exact loss on pairs like USDCAD, GBPUSD, EURUSD, USDCHF, etc but can't predict the exact loss on pairs like EURGBP, EURCAD, EURJPY, GBPJPY, GBPAUD, etc...
But if you can't predict the exact loss value, you can still estimate what it would be if the conversion rate to your account currency would not change between your position's open and close.
And just so people know, I couldn't have understood all this without your help because you were the only right about how the order type doesn't matter in the conversion but that what matters is if it's a profit or loss and how the conversion rate represents your account currency as either the base or quote currency. So thanks!but in your example we don't know the EURAUD bid price at the time of the close, but we can isolate X to find out
...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.
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.
can you find what was the bid and ask on GBPAUD when the trade was opened?
I just want to check something, maybe it doesn't matter but if you have it I'd like to test something...
can you find what was the bid and ask on GBPAUD when the trade was opened?
I just want to check something, maybe it doesn't matter but if you have it I'd like to test something...
Sure.
The trade was open at D'2022.08.03 15:44:00.887'
Alain, please show the tick and close time in milliseconds.
I already provide these data in the topic, not ?