TICK_VALUE for non account currency pair

 

I need to calculate tick value for currecy pair that does not include account currency, but getting different from defult SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE) result.


Can someone please point me on what I'm doing wrong here?


void OnStart()
{
  const string symbol = "EURGBP"; //-symbol of interest
  const string acc    = "USD";    //-account currency

  const string base = SymbolInfoString(symbol, SYMBOL_CURRENCY_BASE);
  const string prof = SymbolInfoString(symbol, SYMBOL_CURRENCY_PROFIT);

  //-MQL5 default method for calculating TICK_VALUE:
  const double expected =
    SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE)
    / SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE)
    * SymbolInfoDouble(symbol, SYMBOL_POINT);

  //-my method to calculate TICK_VALUE:
  const double result =
    SymbolInfoDouble(base + acc, SYMBOL_BID)
    / SymbolInfoDouble(symbol, SYMBOL_BID);

  Print("tickvalue expected: ", expected, " result: ", result);

  if(result != expected) Print("test failed!");
  else Print("test pass OK");
} 


Sample output:

2021.04.18 01:27:44.534	test-tick-value-to-forum-question (EURGBP,M15)	tickvalue expected: 1.38401 result: 1.384179028605758
2021.04.18 01:27:44.534	test-tick-value-to-forum-question (EURGBP,M15)	test failed!

 
terminalstat: I need to calculate tick value for currecy pair that does not include account currency, but getting different from defult SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE) result.Can someone please point me on what I'm doing wrong here?

I'm not quite sure what it is you are trying to calculate, but please note that the Tick Value obtained by the "SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE)" is already expressed in your account's deposit currency and does not need to be "converted".

EDIT: Maybe you already know that and I'm just misunderstanding what it is you are trying to achieve. Can you provide more details please so we can better understand the context?

 
Fernando Carreiro:

I'm not quite sure what it is you are trying to calculate, but please note that the Tick Value obtained by the "SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE)" is already expressed in your account's deposit currency and does not need to be "converted".

EDIT: Maybe you already know that and I'm just misunderstanding what it is you are trying to achieve. Can you provide more details please so we can better understand the context?

Thanks for your reply. What I want is to have my custom way to calculate SYMBOL_TRADE_TICK_VALUE.

SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE) == MyCustomTickValCalculator(symbol)

As you correctly mentione regular MQL5 function is already used for reference value here (stored in variable 'expected')

My method returns to 'result' var.

I'm getting different values, can't understand why?

 
terminalstat:

Thanks for your reply. What I want is to have my custom way to calculate SYMBOL_TRADE_TICK_VALUE.

SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE) == MyCustomTickValCalculator(symbol)

As you correctly mentione regular MQL5 function is already used for reference value here (stored in variable 'expected')

My method returns to 'result' var.

I'm getting different values, can't understand why?

I've never thought about that, but maybe it has to do with the Spread, namely, maybe it should be Bid/Ask and not Bid/Bid! Just a guess, I'm not actually sure.
 
Fernando Carreiro:
I've never thought about that, but maybe it has to do with the Spread, namely, maybe it should be Bid/Ask and not Bid/Bid! Just a guess, I'm not actually sure.

I tried all combinations)) no luck

 

Just did a test with Bid/Ask with your code and the results seem closer:

2021.04.17 23:24:00.544 testtickvalue EURGBP,H1: tickvalue expected: 1.38390000 result: 1.38387794
EDIT: In this case of Bid/Ask, the difference might just be rounding of the Tick Value!
 
Fernando Carreiro:

Just did a test with Bid/Ask with your code and the results seem closer:

EDIT: In this case of Bid/Ask, the difference might just be rounding of the Tick Value!

Updated code for more clearance.

Your result looks good enough to be rounded, but I just ran with Bid/Ask:

2021.04.18 01:32:13.715 test-tick-value-to-forum-question (EURGBP,M15)  tickvalue expected: 1.38401 result: 1.383843284013075

.. and it seems mine still not good enough. May be it's a broker. Which one you use?

 
Fernando Carreiro:

Just did a test with Bid/Ask with your code and the results seem closer:

EDIT: In this case of Bid/Ask, the difference might just be rounding of the Tick Value!

Also I beleave we are talking the same Bid/Ask?

  //-my method to calculate TICK_VALUE:
  const double result =
    SymbolInfoDouble(base + acc, SYMBOL_BID)
    / SymbolInfoDouble(symbol, SYMBOL_ASK);
 
terminalstat: Also I beleave we are talking the same Bid/Ask?

Yes, that is correct! I also tried all the combinations, including with Mid Price, both on MetaTrader 4 and 5 but it is closest on MetaTrader 4 and worse on MetaTrader 5

MetaTrader 5:

2021.04.17 23:42:31.612 testtickvalue (EURGBP,H1)       BID/BID - tickvalue expected: 1.38383000 result: 1.38445271
2021.04.17 23:42:31.612 testtickvalue (EURGBP,H1)       BID/ASK - tickvalue expected: 1.38383000 result: 1.38371717
2021.04.17 23:42:31.612 testtickvalue (EURGBP,H1)       ASK/BID - tickvalue expected: 1.38383000 result: 1.38486873
2021.04.17 23:42:31.612 testtickvalue (EURGBP,H1)       ASK/ASK - tickvalue expected: 1.38383000 result: 1.38413296
2021.04.17 23:42:31.612 testtickvalue (EURGBP,H1)       MID/MID - tickvalue expected: 1.38383000 result: 1.38429279

MetaTrader 4:

2021.04.17 23:46:27.721 testtickvalue EURGBP,H1: BID/BID - tickvalue expected: 1.38390000 result: 1.38445361
2021.04.17 23:46:27.721 testtickvalue EURGBP,H1: BID/ASK - tickvalue expected: 1.38390000 result: 1.38387794
2021.04.17 23:46:27.721 testtickvalue EURGBP,H1: ASK/BID - tickvalue expected: 1.38390000 result: 1.38470783
2021.04.17 23:46:27.721 testtickvalue EURGBP,H1: ASK/ASK - tickvalue expected: 1.38390000 result: 1.38413204
2021.04.17 23:46:27.721 testtickvalue EURGBP,H1: MID/MID - tickvalue expected: 1.38390000 result: 1.38429279
 

Just did a search and found this: https://www.mql5.com/en/forum/187683

How is TickValue calculated?
How is TickValue calculated?
  • 2017.03.21
  • www.mql5.com
Hello,I would like to know how the Tick value is calculated for pairs in which the account currency is not present...
 

If I follow the logic in your code, you are applying the following logic - Is this correct?

(EUR/USD) / (EUR/GBP) = (EUR/USD) * (GBP/EUR) = GBP/USD