Download MetaTrader 5

SymbolInfoDouble returns SYMBOL_LAST propert of a symbol just for one time

To add comments, please log in or register
amin_mohammadi
87
amin_mohammadi  

Hello everyone,

I need help with SYMBOL_LAST property in SymbolInfoDouble() function

   string ls;


   matL.Resize(8,8);
   mat.Resize(8,8);
   double Arr[];

   for(int i=0;i<8;i++)
     {
      for(int j=0;j<8;j++)
        {
         str=currency.Major[i];
         str2=currency.Major[j];
         double bid=SymbolInfoDouble(currency.Major[i]+currency.Major[j]+".m",SYMBOL_BID);

         if(bid>0)
           {
           
            string temp=str+str2+".m";
            last=SymbolInfoDouble(temp,SYMBOL_LAST);// returns 0 after the first time
            if(CopyClose(str+str2+".m",0,0,2,Arr)>0)
              {
               double val=((last-Arr[1])/Arr[1])*100;
              
               mat[i].Set(j,val);
               mat[j].Set(i,1/val);
              }
            else
              {

               mat[i].Set(j,0);
              }

           }
         else if(SymbolInfoDouble(str2+str+".m",SYMBOL_BID)>0)
           {
            last=SymbolInfoDouble(str2+str+".m",SYMBOL_LAST); // returns 0 after the first time
            bid=SymbolInfoDouble(str2+str+".m",SYMBOL_BID);

            if(CopyClose(str2+str+".m",0,0,2,Arr)>0)
              {
               double val=((last-Arr[1])/Arr[1])*100;
              
               mat[j].Set(i,val);
               mat[i].Set(j,1/val);
              }
            else
              {
               mat[j].Set(i,0);

              }

           }
         else if(str==str2)
           {

            mat[i].Set(j,1);
           }
        }

     }

I need to get the last price of a symbol in my code, but the function just returns the last price just for one time.

why?

thank you.

Alain Verleyen
Moderator
33493
Alain Verleyen  
In case you get a 0 value, use GetLastError() to see why. Read documentation of SymbolInfoDouble.
Documentation on MQL5: Checkup / GetLastError
Documentation on MQL5: Checkup / GetLastError
  • www.mql5.com
Checkup / GetLastError - Documentation on MQL5
amin_mohammadi
87
amin_mohammadi  
angevoyageur:
In case you get a 0 value, use GetLastError() to see why. Read documentation of SymbolInfoDouble.

The error code is 4301 which is "Unknown Symbol".

but the same symbol works for SYMBOL_BID.

To add comments, please log in or register