Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 244

 
for(int i=0;i<=1440;i++)
     {
      datetime bar_time=iTime(NULL,0,i);
      if(bar_time==0) Print(__FUNCTION__+": iTime failed. Error=",GetLastError());
     }

Why do I always get bar_time 0 and error 4051?

 
igorbel: Why do I always get bar_time 0 and error 4051?
//+-------------------------------------------------------+
//| почему 4051                                           |
//+-------------------------------------------------------+
#property strict
void OnStart()
{
  Alert("Bars = ",Bars);
  for(int i=Bars-3;i<=Bars+1;i++)  // Догадайтесь, как правильно!!!
  {
    datetime bar_time=iTime(NULL,0,i);
    if(bar_time==0) Alert("Бар = ", i, "  ",__FUNCTION__+": iTime failed. Error=",GetLastError());
    else Alert("Бар = ", i, "  bar_time = ",bar_time);    // Алерт лучше Принт. И подробнее выводите информацию
  }
} 


 

Hello,

I have a link: http://bhashsms.com/api/sendmsg.php?user=userid&pass=userpass&sender=senderid&phone=mobile&text=alertmessage&priority=ndnd&stype=normal

This link sends a text message to your phone if you fill in your username, password and other fields. The link works by inserting it into the browser.

I'm trying to do it like this:

void SMSapi(string userID,string password,string senderID,string phone,string text) 
  { 
   int    res;     
   char   data[];  

   string str="user="+userID+
              "&pass="+password+
              "&sender="+senderID+
              "&phone="+phone+
              "&text="+text+
              "&priority=ndnd&stype=normal"; 

   ArrayResize(data,StringToCharArray(str,data,0,WHOLE_ARRAY,CP_UTF8)-1); 

   res=WebRequest("GET","http://bhashsms.com/api/sendmsg.php",NULL,0,data,data,str); 
   Print(res);
}

But the result = -1. I read that if "...sendmsg.php?..." link has "?" sign in it, it should be "GET" request, I tried the same "POST" request but the result is negative.

Please help me to make a correct request.

Thank you.

 
STARIJ:



In iTime, is the indexing not like in timeseries? Not backwards (the newest bar is zero)?

 
Maksym Mudrakov:

Hello,

I have a link: http://bhashsms.com/api/sendmsg.php?user=userid&pass=userpass&sender=senderid&phone=mobile&text=alertmessage&priority=ndnd&stype=normal

This link sends a text message to your phone if you fill in your username, password and other fields. The link works by inserting it into the browser.

I'm trying to do it like this:

But the result = -1. I read that if "...sendmsg.php?..." link has "?" sign in it, it should be "GET" request, I tried the same "POST" request but the result is negative.

Please help me to make a correct request.

Thank you.

I have also tried a different request:

void SMSapi_2(string userID,string password,string senderID,string phone,string text){ 
  
   string cookie=NULL, headers;
   char post[],result[]; 
   int res; 
   int timeout=5000; 
   char   data[];  

   string str="user="+userID+
              "&pass="+password+
              "&sender="+senderID+
              "&phone="+phone+
              "&text="+text+
              "&priority=ndnd&stype=normal"; 
              
   string url="http://bhashsms.com/api/sendmsg.php?"+str;

   res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers);   

   Print(res);
}

does not work, the result is negative.

 
igorbel: In iTime, is the indexing not like in timeseries? Not backwards (the newest bar is zero)?
  for(int i=0;i<=4;i++)
   Alert("Бар = ", i, "  bar_time = ",iTime(NULL,0,i));
Quicker to check than to shake the forum
 
STARIJ:
Quicker to check than to shake the forum

In any case there will be a problem if you start the test in the current month and use PERIOD_MN1. I wrote about this in post #2429.

 
Nauris Zukas:

In any case there will be a problem if you start the test in the current month and use PERIOD_MN1. I wrote about this in post #2429.


Remind me. I'll try to reproduce it.

(Just give me the link).

 
Victor Nikolaev:

Remind me. I'll try to reproduce it.

(Just give me the link.)

https://www.mql5.com/ru/forum/160683/page243

Любые вопросы новичков по MQL4, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4, помощь и обсуждение по алгоритмам и кодам
  • 2017.06.30
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 

Can you tell me what to do if the Market does not work in the terminal?

Reason: