iTime() returns with zero, unexpectedly

 

Hi,


By using iTime() I found an interesting situation

I have opened the USDCHF M1 chart, and put into a script Print(iTime("USDCHF", PERIOD _M1,0)) it returned with 0.

When I replaced "USDCHF" with Symbol() , Print(iTime(Symbol(), PERIOD _M1,0)); worked well.

Can somebody help me ?


Thank you

F.

 

can you please print this:

 Print("USDCHF: ",iTime("USDCHF", PERIOD _M1,0)," ",Symbol(),": ",iTime(Symbol(), PERIOD _M1,0));

and show it here?

 
paf01200:

Hi,


By using iTime() I found an interesting situation

I have opened the USDCHF M1 chart, and put into a script Print(iTime("USDCHF", PERIOD _M1,0)) it returned with 0.

When I replaced "USDCHF" with Symbol() , Print(iTime(Symbol(), PERIOD _M1,0)); worked well.

You should have received a compiler error for PERIOD and _M1  there should be no space.  If that is just a typo then the most likely issue is that you have an incorrect symbol name,  please post a screen shot of your USDCHF M1 chart so we can check that the symbol name is actually USDCHF and not USDCHFx or something else that is not USDCHF . . .

Note:

 

 

Hi,

Thank you for your respond

Here is the test script I wrote, and I also attached the screenshot of the output

USDCHF screenshot

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   int i=1;
   string curr= "USDCHF";
      Print( Time[0]," " ,iTime(curr,PERIOD_M1,0), " ");
   Alert (GetLastError());
  Print("Current bar for USDCHF M1: ",iTime("USDCHF",PERIOD_M1,i),", ",  iOpen(Symbol(),PERIOD_M1,i),", ",
                                     iHigh("USDCHF",PERIOD_M1,i),", ",  iLow("USDCHF",PERIOD_M1,i),", ",
                                     iClose("USDCHF",PERIOD_M1,i),", ", iVolume("USDCHF",PERIOD_M1,i));
Print("USDCHF: ",iTime("USDCHF", PERIOD_M1,0)," ",Symbol(),": ",iTime(Symbol(), PERIOD_M1,0));
//----
   return(0);
  }
//+------------------------------------------------------------------+

 
paf01200:

Hi,

Thank you for your respond

Here is the test script I wrote, and I also attached the screenshot of the output

<CODE DELETED>

Please   edit    your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 
 
paf01200:

Hi,

Thank you for your respond

Here is the test script I wrote, and I also attached the screenshot of the output

Here is what your script outputs on my terminal:

USDCHF script 

 
RaptorUK:
Please   edit    your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 
Thanks, I followed your advice Mr RaptorUK
int start()
  {
//----
   int i=1;
   string curr= "USDCHF";
      Print( Time[0]," " ,iTime(curr,PERIOD_M1,0), " ");
   Alert (GetLastError());
  Print("Current bar for USDCHF M1: ",iTime("USDCHF",PERIOD_M1,i),", ",  iOpen(Symbol(),PERIOD_M1,i),", ",
                                     iHigh("USDCHF",PERIOD_M1,i),", ",  iLow("USDCHF",PERIOD_M1,i),", ",
                                     iClose("USDCHF",PERIOD_M1,i),", ", iVolume("USDCHF",PERIOD_M1,i));
Print("USDCHF: ",iTime("USDCHF", PERIOD_M1,0)," ",Symbol(),": ",iTime(Symbol(), PERIOD_M1,0));
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Thirteen:

Here is what your script outputs on my terminal:


I get this . . .

2013.06.05 17:00:30 iTime-Test USDCHF,M1: removed

2013.06.05 17:00:30 iTime-Test USDCHF,M1: uninit reason 0

2013.06.05 17:00:30 iTime-Test USDCHF,M1: USDCHF: 1370458800 USDCHF: 1370458800

2013.06.05 17:00:30 iTime-Test USDCHF,M1: Current bar for USDCHF M1: 1370458740, 0.9424, 0.9424, 0.9421, 0.9421, 26

2013.06.05 17:00:30 iTime-Test USDCHF,M1: Alert: 0

2013.06.05 17:00:30 iTime-Test USDCHF,M1: 1370458800 1370458800 

2013.06.05 17:00:29 iTime-Test USDCHF,M1: loaded successfully

 
paf01200:
Thanks, I followed your advice Mr RaptorUK

Except you didn't,  please   edit    your earlier post.
 
int start()
  {
//----
   int i=1;
   string curr= "USDCHF";
      Print( Time[0]," " ,iTime(curr,PERIOD_M1,0), " ");
   Alert (GetLastError());
 // Print("Current bar for USDCHF M1: ",iTime("USDCHF",PERIOD_M1,i),", ",  iOpen(Symbol(),PERIOD_M1,i),", ",
                                  //   iHigh("USDCHF",PERIOD_M1,i),", ",  iLow("USDCHF",PERIOD_M1,i),", ",
                                  //   iClose("USDCHF",PERIOD_M1,i),", ", iVolume("USDCHF",PERIOD_M1,i));
Print("USDCHF: ",iTime("USDCHF", PERIOD_M1,0)," ",Symbol(),": ",iTime(Symbol(), PERIOD_M1,0));

if (Symbol()!= "USDCHF")
   Print(" DIFF"  , Symbol(), "USDCHF");
else
   Print ("OK");
       
//----
   return(0);
  }

USDCHF V2

I modified the script it seems so that Symb not equal with "EURUSD"

Any idea

Thank you:


Ferenc

 
paf01200:


I modified the script it seems so that Symb not equal with "EURUSD"

Any idea

Thank you:


Ferenc

Looks to me (from your screen shots) that the broker's symbol name for the Swiss Franc is actually "USDCHF." rather than "USDCHF".  Notice the period (".") next to the "F"?  From your latest screen shot, it looks like the broker's symbol name for euro is also appended with a period: "EURUSD." rather than "EURUSD".  That explains why your script works on my terminal and on RaptorUK's terminal, but not on your terminal.  If you use "USDCHF." (rather than "USDCHF") in your script, I think it should work.
Reason: