wrong value for SYMBOL_TRADE_TICK_VALUE - page 3

 
jossnet #: Hi fernando, ok,  but i get a compiler error not an call error  i mean  this ->'SYMBOL_TRADE_TICK_TICK_VALUE' - undeclared identifier XAUUSD_GPT4.mq5 148 48
As already pointed out, it was a typographical error. It is not " SYMBOL_TRADE_TICK_TICK_VALUE " but instead it is "SYMBOL_TRADE_TICK_VALUE" as you have used correctly in your code example and in my code as well.
 
Don't ask me why, but XAUUSD and USDJPY often have these problems.

My way of solving it is as follows:
double TickSize = SymbolInfoDouble ( _Symbol , SYMBOL_TRADE_TICK_SIZE );
double LotSize = SymbolInfoDouble ( _Symbol , SYMBOL_TRADE_CONTRACT_SIZE );
double TickValue = LotSize * TickSize;

This is how I get the tick value when the symbol gives me trouble with SYMBOL_TRADE_TICK_VALUE .

 
Miguel Angel Vico Alba #:Don't ask me why, but XAUUSD and USDJPY often have these problems. My way of solving it is as follows: This is how I get the tick value when the symbol gives me trouble with SYMBOL_TRADE_TICK_VALUE .
That only works if your Account Currency is in USD. If not, then you have to convert it.
 
Fernando Carreiro #:
That only works if your Account Currency is in USD. If not, then you have to convert it.
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double CalculateTickValue(const string pSymbol)
  {
   double TickSize = SymbolInfoDouble(pSymbol, SYMBOL_TRADE_TICK_SIZE);
   double LotSize = SymbolInfoDouble(pSymbol, SYMBOL_TRADE_CONTRACT_SIZE);
   double TickValue = LotSize * TickSize;

   const string prof = SymbolInfoString(pSymbol, SYMBOL_CURRENCY_PROFIT);
   const string acc  = AccountInfoString(ACCOUNT_CURRENCY);
//--- converting into deposit currency.
   if(prof != acc)
     {
      TickValue *= GetCrossRate(prof, acc);
     }

   return TickValue;
  }
//+------------------------------------------------------------------+
//| Returns the cross-rate for the base/profit currency pair.        |
//+------------------------------------------------------------------+
double GetCrossRate(string base_currency, string profit_currency)
  {
   if(base_currency == profit_currency)
     {
      return (1.0);
     }
//---
   string symbol = GetSymbolByCurrencies(base_currency, profit_currency);
   if(symbol != NULL)
     {
      double bid = SymbolInfoDouble(symbol, SYMBOL_BID);
      return (bid);
     }
//--- Try the inverse symbol
   symbol = GetSymbolByCurrencies(profit_currency, base_currency);
   if(symbol != NULL)
     {
      double ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
      return (!ask) ? 0.0 : (1 / ask);
     }
//---
   Print(__FUNCTION__, ": Error, cannot get cross rate for ", base_currency + profit_currency);
   return (0.0);
  }
 
jossnet #: 3. gently could someone give me a snippet of code ( a few lines ) of what  you mean or do when you say " the current EURUSD rates to convert from the USD to EUR value  " and make the conversion for my own ?
Please note that the issue about the Tick Value and how to calculate it has been discussed on the forum many times. It may be wise to do a search and read up on those many threads many of which have code examples for the calculations.
 
Miguel Angel Vico Alba #:
I am unable to comment much more as I have never had need for extra calculations. Luckily all the brokers I have used provide a valid tick value.
 
Fernando Carreiro #:
I am unable to comment much more as I have never had need for extra calculations. Luckily all the brokers I have used provide a valid tick value.

As I said before I have always found these problems with gold and USDJPY in different brokers depending on whether you have 2 or 3 decimal places.

It is something that has been like this for years and I do not understand why.  😥

 

Some broker have wrong tick value but profit is true.

try use the function, I also get it from forum 

double GetTickValue(string symbol = NULL)
  {
   if(symbol == NULL)
      symbol = _Symbol;
   double Price = SymbolInfoDouble(symbol, SYMBOL_ASK);
   double TickSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
   double Profit = 0;
   if(OrderCalcProfit(ORDER_TYPE_BUY, symbol, 1, Price, Price + TickSize, Profit) && Profit > 0)
      return Profit;
   return (SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE));
  }
 
@Trinh Dat #: Some broker have wrong tick value but profit is true. try use the function, I also get it from forum 
That seems like an interesting workaround. Thank you. It is good to know!
 
@Miguel Angel Vico Alba  :thanks for the snippet. i'll give it a try immidiatly.
@Fernando Carreiro  : I apologies for this. I usually try to read a tons of posts searching for a matching of my  need with posts and not to burden you in the group with work. i could not immagine of broken config.  In any case thank for your patience.
 
Miguel Angel Vico Alba
Miguel Angel Vico Alba
  • 2023.03.31
  • www.mql5.com
Trader's profile
Reason: