Learning and writing together in MQL5 - page 5

 
maxandsoft :

The point is that when I compile it during debugging it throws me back to the MQL editor without even giving an error. And when I just pull the EA to a chart, it doesn't even show up on it. I.e. neither debugging nor launching the EA gives errors anywhere


I found an error but it says DLL is not allowed - i.e. I don't see it. The question is where it should be? (in version 4 it did not need to be overwritten anywhere, it was by default in the Systems folder of Windows)

 
maxandsoft   :


But I found an error saying DLL is not allowed - i.e. it can't see it. The question is where should it be located? (in version 4 it did not need to be overwritten anywhere, it was by default in the Systems folder of Windows)

Try to allow import from a DLL


 

I think the difference between a good compiler and a bad compiler is that you can use it to cull non-viable code from viable code. And this is the main thing. You often come across things that are breathtaking and don't exist in any technical context. That contributes to the development and refinement of the expressive means of the language. And if you have to worry about what format to enter it in - it's not the compiler, it's ... In my opinion, the compiler in MQL5 needs improvement no less than the program interface.

 
Rosh   :

Try allowing import from a DLL

Now this is what it says

2010.01.14:27:56 GetInternet (EURJPY,H1) Access violation read to 0x00040017 in 'C:\Users\FujitsuAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Libraries\winet.dll'

 
maxandsoft   :

Now this is what it says

2010.01.14:27:56 GetInternet (EURJPY,H1) Access violation read to 0x00040017 in 'C:\Users\FujitsuAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Libraries\winet.dll'

Please attach source code. Can be sent as a private message.
 
mql5   :

Please attach the source text. Can be sent as a private message.

//+------------------------------------------------------------------+
//|                                                  GetInternet.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#import "wininet.dll"
  int InternetAttemptConnect (int x);
  int InternetOpenA(string sAgent, int lAccessType, 
                    string sProxyName = "", string sProxyBypass = "", 
                    int lFlags = 0);
  int InternetOpenUrlA(int hInternetSession, string sUrl, 
                       string sHeaders = "", int lHeadersLength = 0,
                       int lFlags = 0, int lContext = 0);
          
  int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead, 
                       int& lNumberOfBytesRead[]);
  int InternetCloseHandle(int hInet);



#import
input int Step = 300;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("Старт...");
   

//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
    Comment(GetURL("http://www.forexremote.net"));
    
  }
//+------------------------------------------------------------------+


//+----------------------------------------------------------------------------------------------------------+
//| Функция получения WEB страницы                                                                           |
//+----------------------------------------------------------------------------------------------------------+
string GetURL(string url)
{
   int rv = InternetAttemptConnect(0);
   if(rv != 0)
     {
       Alert("Ошибка при вызове InternetAttemptConnect()");
       return("");
     }

   int hInternetSession = InternetOpenA("Microsoft Internet Explorer", 1, "", "", 0);
   if(hInternetSession <= 0)
     {
       Alert("Ошибка при вызове InternetOpenA()");
       return("");         
     }

   int hURL = InternetOpenUrlA(hInternetSession, url, "", 0, 0, 0);
   if(hURL <= 0)
    {
       Print("Ошибка получения данных с узла!");
       //fComment("Ошибка получения данных с узла!",true);
       InternetCloseHandle(hInternetSession);
       return("");         
     } 
          
   int cBuffer[256];
   int dwBytesRead[1]; 
   string TXT = "";
   while(!IsStopped())
     {
       bool bResult = InternetReadFile(hURL, cBuffer, 1024, dwBytesRead);
       if(dwBytesRead[0] == 0)
           break;
       string text = "";   
       for(int i = 0; i < 256; i++)
         {
              text = text + CharToString(cBuffer[i] & 0x000000FF);
              if(StringLen(text) == dwBytesRead[0])
                  break;
              text = text + CharToString(cBuffer[i] >> 8 & 0x000000FF);
              if(StringLen(text) == dwBytesRead[0])
                  break;
           text = text + CharToString(cBuffer[i] >> 16 & 0x000000FF);
           if(StringLen(text) == dwBytesRead[0])
               break;
           text = text + CharToString(cBuffer[i] >> 24 & 0x000000FF);
         }
       TXT = TXT + text;
       //Sleep(500);

     }
     InternetCloseHandle(hInternetSession);
     return(TXT);
}
//+----------------------------------------------------------------------------------------------------------+
//| Конец Функции получения WEB страницы                                                                     |
//+----------------------------------------------------------------------------------------------------------+
 
maxandsoft:
Now this is what it says.

2010.01.14:27:56 GetInternet (EURJPY,H1) Access violation read to 0x00040017 in 'C:\Users\FujitsuAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Libraries\winet.dll'

Thank you for your message, the bug has been fixed. Wait for an update.
 

er... with build 239 the error is gone, but not quite...

2010.01.14 23:55:33 GetInternet (USDJPY,H1) Error getting data from node!

As it turned out, the reason for the latter was the functions, replacing them with unicode

InternetOpenW() and InternetOpenUrlW()

I've slightly* solved the problem...

Only I did not use Expert Advisor, I corrected code as a script.


*slightly, only because it was left to defeat the ytf-8 encoding of the site:

<th width="50">&nbsp;PЎѕÐsбщеÐÑœЏ&nbsp;</th>

 
kombat:

er... with build 239 the error is gone, but not quite...

2010.01.14 23:55:33 GetInternet (USDJPY,H1) Error getting data from node!

As it turned out, the reason for the latter was the functions, replacing them with unicode

InternetOpenW() and InternetOpenUrlW()

I've slightly* solved the problem...

Only I did not use Expert Advisor, I corrected code as a script.


*slightly, only because it was left to defeat the ytf-8 encoding of the site:

<th width="50">&nbsp;PЎѕÐsбщеÐÑœЏ&nbsp;</th>

 
maxandsoft:
waiting for the new build