[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 161

 
Vinin:

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)
Search for bar by time. The function returns the offset of the bar to which the specified time belongs. If there is no bar for the specified time (a "gap" in the history), the function, depending on the exact parameter, returns -1 or the shift of the nearest bar.
Thanks a lot, I remember it was there somewhere and it's a problem to find it!
 

Here is the code for the script:

int start()
{
   int n=0, m=7, t=2, k;
   string s;
   for(n=0;k<10000;t++)
   {k=t*4/2;
   Print("k=", k);}

   return(0);
}

When running the script, a message is displayed in the Expert Log:

2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=10000
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9998
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9996
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9994
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9992
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9990
......................................................
......................................................
......................................................
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9576
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9574
2012.06.03 19:16:39     Task1.4_hoz AUDUSD,M15: k=9572

I.e. the value of k starts from 9572, and it should be the first value t*4/2 = 2*4/2 = 4. What is the snag?

 
hoz:

Here is the code for the script:

When running the script, a message is displayed in the Expert Log:

I.e. the value of k starts from 9572, and it should be the first value t*4/2 = 2*4/2 = 4. What is the snag?


Look in the logs
 
Vinin:

Look at the logs

I purposely deleted all the logs. Then I ran the script again and this is what I saw in the logs after that:

21:07:13 MetaTrader 4.00 build 402 started (Nord Group Investments Inc.)
21:07:13 Custom indicator Igel-Spread AUDUSD,M15: loaded successfully
21:07:17 Script birt's patch AUDUSD,M15: loaded successfully
21:07:17 '3176404': connect failed [Старая версия]
21:07:18 Script birt's patch AUDUSD,M15: removed
21:07:29 Script Task1.4_hoz AUDUSD,M15: loaded successfully
21:07:29 Script Task1.4_hoz AUDUSD,M15: removed
21:08:24 Custom indicator Igel-Spread AUDUSD,M15: removed
21:08:24 MetaTrader 4.00 build 402 stopped

No errors other than the system asking me to update the terminal, but I don't need that for a test terminal as I have standing scripts not working on later versions of MT4.

How may this logs help?

By the way. I noticed that the initial value of variable k outputted by Print operator always starts from different values (+- couple of hundred).

 
hoz:

I purposely deleted all the logs. Then I ran the script again and this is what I saw in the logs after that:

No errors other than the system asking me to update the terminal, but I don't need that for a test terminal as I have standing scripts not working on later versions of MT4.

How may this logs help?

By the way. I noticed that the initial value of variable k outputted by Print operator always starts from different values (+- couple of hundred).

Victor, I told you to look in the logs. All information is output there: not only compilation errors, but also the results of the Print operation. The log only shows what is possible (Print is a rather "slow" operator).
 
Thank you, I got it! The whole reason is the operator's slowness... it only outputs part of the data.
 
hoz:
Thank you, I got it! The whole reason is the operator's slowness... it only outputs part of the data.

Slow... yes, but it gets everything out!

 
r772ra:

Slow... yes, but it gets everything out!

It doesn't work for me if there's a lot to output... almost 10k lines.
 
hoz:
It doesn't work for me if I have a lot to output... almost 10k lines.
try it instead of 10000: 100,1000
 
I can't open a new demo account, I have filled everything in, I have checked I agree to the terms and conditions, I press green bar and the new login and password do not come out, the fields are also empty, do you know what is wrong?
Reason: