TickValue in mq5

 

please what is the correct formula for mq5 when mq4 is like this   ?


MarketInfo(ExtSymbols[i], MODE_TICKVALUE)
 

its  SYMBOL_TRADE_TICK_VALUE from this function

https://www.mql5.com/en/docs/marketinformation/symbolinfodouble

Documentation on MQL5: Market Info / SymbolInfoDouble
Documentation on MQL5: Market Info / SymbolInfoDouble
  • www.mql5.com
SymbolInfoDouble - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
thank you, its correct?
double pip = SymbolInfoDouble(ExtSymbols[i],SYMBOL_TRADE_TICK_VALUE)*10;
 
Zbynek Liska #:
thank you, its correct?

No this is the value of one point (_Point) in Deposit currency amount for one lot.

You are looking for 

double pt=_Point;

The pip is not available directly and in my opinion you should skip the term and notion of it . Go directly to the _Point (point/tick) which is the smallest movement an asset can have , and , its available programmatically .

Whenever someone mentions pips in their requests ask "Oh god , are you an analyst , you know what happens after it happens ?" etc (humor)

Also 

SymbolInfoDouble(your_symbol,SYMBOL_POINT);
 
Zbynek Liska #: thank you, its correct?

No! It is the Tick Value, not a "pip" nor even a pip value. Also the function works for both MQL4+ and MQL5.

Forum on trading, automated trading systems and testing trading strategies

Symbol Point Value

Fernando Carreiro, 2022.05.18 21:05

double
   dbTickSize   = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_SIZE  ), // Tick size
   dbTickValue  = SymbolInfoDouble( _Symbol, SYMBOL_TRADE_TICK_VALUE ), // Tick value
   dbPointSize  = SymbolInfoDouble( _Symbol, SYMBOL_POINT ),            // Point size
   dbPointValue = dbTickValue * dbPointSize / dbTickSize;               // Point value

Remember, it's best to use tick size and tick value in your calculations, instead of point size and its value.

Forum on trading, automated trading systems and testing trading strategies

Symbol Point Value

Fernando Carreiro, 2022.06.02 01:14

Here are two examples from AMP Global (Europe):

  • Micro E-mini S&P 500 (Futures): point size = 0.01, tick size = 0.25, tick value = $1.25
  • EURO STOXX Banks (Stock Index): point size = 0.01, tick size = 0.05, tick value = €2.50
 
Lorentzos Roussos #: No this is the value of one point (_Point) in Deposit currency amount for one lot.
It is the Tick Value, not the point value. See my previous post.
 
Fernando Carreiro #:
It is the Tick Value, not the point value. See my previous post.

Yeah what he is looking for is _Point . The lowest possible movement however is SYMBOL_TRADE_TICK_SIZE , correct.

 
Lorentzos Roussos #: Yeah what he is looking for is _Point . The lowest possible movement however is SYMBOL_TRADE_TICK_SIZE , correct.

Possibly! It is currently unclear what the OP wants, and they probably don't even know the differences between tick, point or pip.

 
Perfect, thank you both very much, but I'm still making a mistake somewhere, see screen.   can't you see at first glance where I'm doing wrong?                      
//+------------------------------------------------------------------+
//|                                                    iExposure.mq5 |
//|                   Copyright 2007-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2007-2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property strict

#property indicator_separate_window
#property indicator_plots 0
#property indicator_buffers 1
#property indicator_minimum 0.0
#property indicator_maximum 0.1

#define SYMBOLS_MAX 1024
#define DEALS          0
#define BUY_LOTS       1
#define BUY_PRICE      2
#define SELL_LOTS      3
#define SELL_PRICE     4
#define NET_LOTS       5
#define PROFIT         6
#define PIP            7

input color InpColor=Navy;  // Text color

string ExtName="Exposure";
string ExtSymbols[SYMBOLS_MAX];
int    ExtSymbolsTotal=0;
double ExtSymbolsSummaries[SYMBOLS_MAX][8];
int    ExtLines=-1;
string ExtCols[9]= {"Symbol",
                     "Deals",
                     "Buy lots",
                     "Buy price",
                     "Sell lots",
                     "Sell price",
                     "Net lots",
                     "Profit",
                     "Pip",
                    };
int    ExtShifts[10]= { 10, 80, 130, 180, 260, 310, 390, 460, 530 };
int    ExtVertShift=14;
double ExtMapBuffer[];
long chartid = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
   IndicatorSetString(INDICATOR_SHORTNAME,ExtName);
   SetIndexBuffer(0,ExtMapBuffer,INDICATOR_CALCULATIONS);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE);
   IndicatorSetInteger(INDICATOR_DIGITS,0);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   int windex=ChartWindowFind(chartid,ExtName);
   if(windex>0)
      ObjectsDeleteAll(windex);

  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   string name;
   int    i,col,line,windex=ChartWindowFind(chartid,ExtName);
//----
   if(windex<0)
      return(rates_total);
//---- header line
   if(ExtLines<0)
     {
      for(col=0; col<9; col++)
        {
         name="Head_"+string(col);
         if(ObjectCreate(chartid,name,OBJ_LABEL,windex,0,0))
           {
            ObjectSetInteger(chartid,name,OBJPROP_XDISTANCE,ExtShifts[col]);
            ObjectSetInteger(chartid,name,OBJPROP_YDISTANCE,ExtVertShift);
            ObjectSetString(chartid,name,OBJPROP_TEXT,ExtCols[col]);
            ObjectSetString(chartid,name,OBJPROP_FONT,"Calibri");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,Navy);
           }
        }
      ExtLines=0;
     }
//----
   ArrayInitialize(ExtSymbolsSummaries,0.0);
   int total=Analyze();
   if(total>0)
     {
      line=0;
      for(i=0; i<ExtSymbolsTotal; i++)
        {
         if(ExtSymbolsSummaries[i][DEALS]<=0)
            continue;
         line++;
         //---- add line
         if(line>ExtLines)
           {
            int y_dist=ExtVertShift*(line+1)+1;
            for(col=0; col<8; col++)
              {
               name="Line_"+string(line)+"_"+string(col);
               if(ObjectCreate(chartid,name,OBJ_LABEL,windex,0,0))
                 {
                  ObjectSetInteger(chartid,name,OBJPROP_XDISTANCE,ExtShifts[col]);
                  ObjectSetInteger(chartid,name,OBJPROP_YDISTANCE,y_dist);
                 }
              }
            ExtLines++;
           }
         //---- set line
         int    digits=(int)SymbolInfoInteger(ExtSymbols[i],SYMBOL_DIGITS);
         double buy_lots=ExtSymbolsSummaries[i][BUY_LOTS];
         double sell_lots=ExtSymbolsSummaries[i][SELL_LOTS];
         double buy_price=0.0;
         double sell_price=0.0;
         double pip = SymbolInfoDouble(ExtSymbols[i],SYMBOL_POINT);
         
         if(buy_lots!=0)
            buy_price=ExtSymbolsSummaries[i][BUY_PRICE]/buy_lots;
         if(sell_lots!=0)
            sell_price=ExtSymbolsSummaries[i][SELL_PRICE]/sell_lots;
         name="Line_"+string(line)+"_0";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,ExtSymbols[i]);
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_1";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(ExtSymbolsSummaries[i][DEALS],0));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_2";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_3";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_price,digits));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_4";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(sell_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_5";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(sell_price,digits));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_6";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_lots-sell_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_7";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(ExtSymbolsSummaries[i][PROFIT],2)); ///(ExtSymbolsSummaries[i][PROFIT],2))
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_8";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(pip*(buy_lots-(sell_lots)*-1),3));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }  
        }
     }
//---- remove lines
   if(total<ExtLines)
     {
      for(line=ExtLines; line>total; line--)
        {
         name="Line_"+string(line)+"_0";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_1";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_2";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_3";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_4";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_5";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_6";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_7";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_8";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
        }
     }
//---- to avoid minimum==maximum
   int bars=iBars(_Symbol,_Period);
   ExtMapBuffer[bars-1]=-1;
//----
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int Analyze()
  {
   double profit;
   int    i,index,total=PositionsTotal();
//----
   for(i=0; i<total; i++)
     {
      if(!PositionGetTicket(i))
         continue;
      if(PositionGetInteger(POSITION_TYPE)!=POSITION_TYPE_BUY && PositionGetInteger(POSITION_TYPE)!=POSITION_TYPE_SELL)
         continue;
      index=SymbolsIndex(PositionGetString(POSITION_SYMBOL));
      if(index<0 || index>=SYMBOLS_MAX)
         continue;
      //----
      ExtSymbolsSummaries[index][DEALS]++;
      profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP)+AccountInfoDouble(ACCOUNT_COMMISSION_BLOCKED);
      ExtSymbolsSummaries[index][PROFIT]+=profit;
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
        {
         ExtSymbolsSummaries[index][BUY_LOTS]+=PositionGetDouble(POSITION_VOLUME);
         ExtSymbolsSummaries[index][BUY_PRICE]+=PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME);
        }
      else
        {
         ExtSymbolsSummaries[index][SELL_LOTS]+=PositionGetDouble(POSITION_VOLUME);
         ExtSymbolsSummaries[index][SELL_PRICE]+=PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME);
        }

     }
//----
   total=0;
   for(i=0; i<ExtSymbolsTotal; i++)
     {
      if(ExtSymbolsSummaries[i][DEALS]>0)
         total++;
     }
//----
   return(total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int SymbolsIndex(string SymbolName)
  {
   bool found=false;
   int  i;
//----
   for(i=0; i<ExtSymbolsTotal; i++)
     {
      if(SymbolName==ExtSymbols[i])
        {
         found=true;
         break;
        }
     }
     
     
 ////

     
     
     
//----
   if(found)
      return(i);
   if(ExtSymbolsTotal>=SYMBOLS_MAX)
      return(-1);
//----
   i=ExtSymbolsTotal;
   ExtSymbolsTotal++;
   ExtSymbols[i]=SymbolName;
   ExtSymbolsSummaries[i][DEALS]=0;
   ExtSymbolsSummaries[i][BUY_LOTS]=0;
   ExtSymbolsSummaries[i][BUY_PRICE]=0;
   ExtSymbolsSummaries[i][SELL_LOTS]=0;
   ExtSymbolsSummaries[i][SELL_PRICE]=0;
   ExtSymbolsSummaries[i][NET_LOTS]=0;
   ExtSymbolsSummaries[i][PROFIT]=0;
   ExtSymbolsSummaries[i][PIP]=0;
//----
   return(i);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
Fernando Carreiro #:

Possibly! It is currently unclear what the OP wants, and they probably don't even know the differences between tick, point or pip.

Ow you meant the Tick value is for the Tick size , yes indeed . Sorry

 
This topic has been moved to the section: Technical Indicators
Reason: