SYMBOL_TRADE_TICK_VALUE_LOSS vs SYMBOL_TRADE_TICK_VALUE_PROFIT - page 5

 
amrali #:

The wrong statement was marked in yellow.

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 conversion pair (first or second).

It is a simple rule: The trade type on the conversion pair is the same as that of the traded pair.

On a trading account in USD:

  • For Buy orders (EURGBP) and direct conversion cross (GBPUSD) ->    buy the cross: Ask is used.
  • For Buy orders (EURCAD) and indirect conversion cross (USDCAD) -> buy the cross: 1/Bid (indirect)
  • For Sell orders (EURGBP) and direct conversion cross (GBPUSD) ->    sell the cross: Bid is used.
  • For Sell orders (EURCAD) and indirect conversion cross (USDCAD) -> sell the cross: 1/Ask (indirect)

" The wrong statement was marked in yellow." yes well I was just pointing out that I used the BID instead of the ASK in that statement but didn't specify how the conversion was made but I clarify it in my 7 rules. 

...

#2 XXX Profits & losses on BUY positions for ACCXXX are converted by multiplying the XXX profits by 1 / ACCXXX POSITION_CLOSE_PRICE(BID)

#3 XXX Profits & losses on SELL positions for ACCXXX are converted by multiplying the XXX profits by 1 / ACCXXX POSITION_CLOSE_PRICE(ASK)

#4 XXX Profits & losses on BUY positions for ZZZXXX are treated the same way as profilts and losses from number #2.

...

supporting test:

 
Alain Verleyen #:

Outlier trades ?

You can't just discard the data which doesn't satisfy your theory. According to history data provided by the platform and the broker, it is what is is, there is no synchronization issue (beside the fact I double checked) because when using the bid doesn't match, using the ask perfectly matches. A wrong tick (bid/ask) could not do that.

Anyway, I don't have an explanation for these facts (EUR account ? real account ? something else ?). I will investigate further.

Thanks for your topic which forced us to dig more deeply. Thanks to amrali. I am glad I learnt new things.

"You can't just discard the data which doesn't satisfy your theory." - the thing is I get different results when I try to replicate your trade type in my account, so my data does fit my theory, it's only yours that doesn't. But I'm running a live test and it never gives me outlier results. So I have to trust my data, even though I can't explain yours. When I test a EURCAD long with my USD account, the conversion is done with 1 / BID. That's the best way for me to reproduce your GBPAUD trade that converts to EUR with EURAUD.

see:


If I were you I would try to replicate this issue with the technique I outlined here:

"Use a demo, open a position for 1 lot, place a stop loss 1000 points away from the entry price, then hover over the stop while at the exact same time the pop-up appears (that tells you the loss value) take a screenshot so that you can see exactly what the server says the loss will be with that stop while also seeing exactly what are the bid and ask on the conversion pair (keep your market watch open so that you see the rates in the screenshot)."

Try to do it with a long trade on GBPAUD, and use the rates you see on your market watch for EURAUD to check how the conversion was made to get the loss value you will see in the pop up when you hover over the stop loss (just make sure you take the screenshot quickly because as soon as the rates change for EURAUD the value you see in the pop-up is no longer valid.

It takes 2 minutes if you have a demo account, let me know what you get...

If you still get 1/ASK, then perhaps it has something to do with your broker or account currency. You'd have to make sure this applies to all trades made with GBPAUD though, not just one. Can you replicate the trade and come out with 1/ASK every time or you only see this once in your history?

 
amrali #:

That's what I said before:

SYMBOL_TRADE_TICK_VALUE_PROFIT  is used only to calculate profit of SELL orders.

SYMBOL_TRADE_TICK_VALUE_LOSS  is used only to calculate profit of BUY orders.

Yeah you were right, I won't use those values though because they use the current rates on the conversion pair but you can know the future rates when your account currency is in the conversion pair and since my account is in USD that's 95% of the pairs I trade so using manual calculations for loss values with stop losses gives me much better results than using the tick value from those variables (except for crosses but then I still don't need those variables because I know exactly how to convert the profits/losses with the conversion pair's bid/ask now so I can do it myself without using variables that frankly have very confusing names for no reason).

By the way these names are probably not right because originally MT5 wasn't created to trade futures (I think) so that's probably language that made more sense when it was first created but makes no more sense today now that people use MT5 as a futures trading platform. It's makes no sense if you think MT5 is an upgrade for MT4 but that's not what MT5 is so that's probably where the confusion comes from. MT4 by the way only has one TICKVALUE variable, no difference for longs/shorts so I would not use that variable in MT4 either if the goal was to calculate your position size, if you know how, you're better off just using the rates to perform manual conversions in my opinion (in both MT4 and MT5).

 

One point to add is that the names are definitely wrong from a logical point of view.

Let me explain it for you:

TICK_VALUE_LOSS (the better name is TICK_VALUE_LONG) is calculated from longing the cross conversion pair (multiply by Ask, or 1/Bid if indirect).

TICK_VALUE_PROFIT (the better name is TICK_VALUE_SHORT) is calculated from shorting the cross conversion pair (multiply by Bid, or 1/Ask if indirect).


Because the conversion pair's Ask >= Bid, so the TICK_VALUE_LOSS (LONG)  >=  TICK_VALUE_PROFIT (SHORT), at any point in time.

If the current names for tick values are really correct, it means that we will have less profits / increased losses trading the cross pairs, especially with expanding spreads on the conversion pair. This means that the platform is stealing our money (fortunately, this does not occur).


The terminal makes the right calculations (although the names of tick values are wrong): i.e., longing the conversion pair for buy profit, and shorting the conversion pair for sell profit, as outlined above. See this screenshot:

 


Now, from the context menu Profit -> as Money is selected.


Notice that, difference in profits between the two positions is due to different trade types (buy vs sell) requiring different rates of conversions, and different tick values. Both positions are losing, so whether the position is profitable or losing does not affect the profit calculations (conversion rates/ tick values). The last statement should be stressed as the names of tick values cause much confusion here.

As a side effect of TICK_VALUE_LOSS (LONG) >=  TICK_VALUE_PROFIT (SHORT), the magnitude of profits or losses of buy positions on the cross pairs will be slightly larger than those from sell positions, having the same volume and the same profit points (hedged positions), as seen in the screenshot above.


This topic is an old debate on the forum, check these links

https://www.mql5.com/ru/forum/6372 

and https://www.mql5.com/en/forum/203824#comment_5276160

 
amrali #:

This is very bizare indeed. Something else I noticed is that in MT4 you don't even have two different built in variables for TICKVALUE so that means that the value the platform gives you is only right half the time.

You also see a lot of articles by reputable sources failing to even mention the difference between the bid and the ask for the exchange rate (they just say convert profits using the conversion rate for the quote currency and your account currency), or they tell you that the function does exactly what the name tells you it does. This is a great example of how in trading and investment, if anyone tells you anything, always verify it for yourself, even if the author is making a lot of effort to convince you that they are a trusted authority on the subject (I'm not referring to people on the forum).

Something else worth noting about all the tutorials on how to calculate position size with tick value is that using this to calculate position size will always give you an incorrect result except if your traded pair has your account currency as the quote currency. For example if your account is in USD, using tick value to calculate position size for a known stop loss placement will only work if you are trading pairs like GBPUSD, EURUSD, AUDUSD, etc, because those pair's tick value will remain constant no matter what price the pair is trading at. It's also only with these pairs that the names for the variables is correct because the tick value is the same for buy and sell orders so it'll be the same for profits and losses. But then no body uses the tick value variables to guess that 1 tick on EURUSD is worth 1 USD.

The tick size and contract size variables make much more sense. With them you can find out for example that 1 tick is equal 1 USD on pairs with USD as the quote currency if the contract size is 100,000 and the minimal price move is 0.00001. Or the same with USDCAD where you know that a tick is always worth 1 CAD if the contract size is 100,000 and the minimal price change is 0.00001. Or that a tick on USDJPY is worth 100 JPY if the contract size is 100,000 and the minimal price move is 0.001. With this information you can easily make your code compatible with different types of brokers or instruments that may use different contract sizes or a different number of digits in their quotes. In fact, you should get those values before you make your conversion to the account currency using either the ASK, 1/ASK, the BID or 1/BID as the multiplier for the conversion pair's exchange rate when needed.

Using these values makes complete sense (tick size and contract size), but not using the tick value variables. That doesn't mean they shouldn't exist on the platform, but more people should know how innacurate they are when used to calculate position size so that they could then avoid using them but that is not the case right now. Maybe our discussion will help, afterall, the title of the thread will be easy to find as anyone who googles SYMBOL_TRADE_TICK_VALUE_LOSS vs SYMBOL_TRADE_TICK_VALUE_PROFIT will see this thread is now the first search result that comes up. You still have to make an effort to understand what were saying because there's a lot of nuance to this calculation but I think everything someone needs to know is now included in this discussion.

Anyway, thanks for the help, all is much more clear now. And to be honest, having to work to understand these functions because of their names being wrong made me learn a lot of things about the math behind profits and losses on a position that I would have never learned had it not been for this error. A week ago I wouldn't have even been able to tell you how to calculate an approximation and now I can easily tell you exact profits or losses for a position on every pair in every direction with any account currency (with the exception of pairs that don't include your account currency in the traded pair but even for those I can still know the optimal calculations to come up with the most accurate approximation).

Just to give you an example, if the names had been correct, I would have probably never realized that for many pairs this won't allow you to calculate the exact values for the loss with a fixed stop loss because I would have never realized that the conversion to your account currency will change as the rates change. So I'm lucky the names were wrong, or else my code would have been wrong!

Thanks again for the debate everyone, hopefully, all is settled now.

 
The tick value has its place in the platform. It is dynamic in nature, and its value has the right profit/account exchange rate (which changes with every tick) as a component . 

You see how it is difficult for causal users to calculate the correct exchange rates (get the right conversion pair, add it to the Market watch, then use the appropriate short or long rate depending on the trade type, and on whether it is direct/indirect).

You must use either the exchange rate or tick values, when calculating profits, losses, position size, swap values and the cost of spread. Tick value can be actually a shorthand replacement for the exchange rate in these situations.
 
amrali #:
The tick value has its place in the platform. It is dynamic in nature, and its value has the right profit/account exchange rate (which changes with every tick) as a component . 

You see how it is difficult for causal users to calculate the correct exchange rates (get the right conversion pair, add it to the Market watch, then use the appropriate short or long rate depending on the trade type, and on whether it is direct/indirect).

You must use either the exchange rate or tick values, when calculating profits, losses, position size, swap values and the cost of spread. Tick value can be actually a shorthand replacement for the exchange rate in these situations.

I agree that this is certainly going to be a bit tough for casual users... But not impossible!

Take your entry - your exit, add the spread, multiply by contract size and tick size, identify the quote currency of the pair and the account currency, find the matching conversion pair (you can build an 2 dimensional string array to make it easier so that you just have to search for the quote currency and then you know what the conversion pair is with the 2nd dimension, you can also add a third dimension that says "direct" or "indirect" to make it easier in the next step), then check the position direction, use conditions to figure out if you need the ask or the bid and 1/x or just x as the multiplier, then you have your loss for 1 lot, calculate your desired risk, use that ratio to adjust your lot size, round to the nearest minimal volume step and you got your position size! If you want to do it like me, incorporate the commission in the equation to get an even better result.

Haha, just kidding, casual users are not going to do this, but hey if you like a challenge, I think it's worth the effort! ;)

 
Jeepack #:

I agree that this is certainly going to be a bit tough for casual users... But not impossible!

Take your entry - your exit, add the spread, multiply by contract size and tick size, identify the quote currency of the pair and the account currency, find the matching conversion pair (you can build an 2 dimensional string array to make it easier so that you just have to search for the quote currency and then you know what the conversion pair is with the 2nd dimension, you can also add a third dimension that says "direct" or "indirect" to make it easier in the next step), then check the position direction, use conditions to figure out if you need the ask or the bid and 1/x or just x as the multiplier, then you have your loss for 1 lot, calculate your desired risk, use that ratio to adjust your lot size, round to the nearest minimal volume step and you got your position size! If you want to do it like me, incorporate the commission in the equation to get an even better result.

Haha, just kidding, casual users are not going to do this, but hey if you like a challenge, I think it's worth the effort! ;)

You did almost all the forex calculations in this example ;-)

 

Calculations using exchange rates are more involved, but  accurate.

   if(ordertype == ORDER_TYPE_BUY)  
       profit = lots * SYMBOL_TRADE_CONTRACT_SIZE * (price_current - price_open) * GetExchangeRate(ProfitCurrency, AccountCurrency, ORDER_TYPE_BUY);
       
   if(ordertype == ORDER_TYPE_SELL) 
       profit = lots * SYMBOL_TRADE_CONTRACT_SIZE * (price_open - price_current) * GetExchangeRate(ProfitCurrency, AccountCurrency, ORDER_TYPE_SELL);

Calculations using tick values are much simple (shorthand), but you count on the correctness of pre-calculated tick values from the terminal. Some brokers have wrong tick values on non-forex symbols, like gold)

   if(ordertype == ORDER_TYPE_BUY)  
       profit = lots * (price_close - price_open) / SYMBOL_TRADE_TICK_SIZE * SYMBOL_TRADE_TICK_VALUE_LOSS(LONG);
       
   if(ordertype == ORDER_TYPE_SELL) 
       profit = lots * (price_open - price_close) / SYMBOL_TRADE_TICK_SIZE * SYMBOL_TRADE_TICK_VALUE_PROFIT(SHORT);

You can invert the above equations to calculate the lot size. For example: lot size buy = risk money / sl_ticks / tick_value_long.


Another interesting observation, is that for symbols which have direct conversion pairs, usually their tick values are the conversion rates, exactly.


 
amrali #:

Calculations using exchange rates are more involved, but  accurate.

Calculations using tick values are much simple (shorthand), but you count on the correctness of pre-calculated tick values from the terminal. Some brokers have wrong tick values on non-forex symbols, like gold)

You can invert the above equations to calculate the lot size. For example: lot size buy = risk money / sl_ticks / tick_value_long.


Another interesting observation, is that for symbols which have direct conversion pairs, usually their tick values are the conversion rates, exactly.


My main complaint about tick value is that it only allows you to get the exact loss value of a stop loss if the traded pair's quote currency is the same as your account's currency. If you are trading a pair that has your account's currency as the base currency, then tick value will not give you the correct loss value for your stop loss. You already know why but for those who don't it's because the loss on your trade will be converted with the close price of the trade which will not be the same as the open price while the tick value uses the open price to convert to your account's currency. So for example, if my account is in USD and I trade USDJPY, the tick value multiplied by the size of the price change and lot size will not give me the correct value for the loss on that trade.

*edit: I think I have an idea to work out a way to get the correct loss size with tick value with a shortcut that skips all the complicated conversions, will post it later tonight
Reason: