Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1015

 
artborder:

if closing by advisor/script, then


arrow_color

[in] The colour of the closing arrow on the chart. If the parameter is missing or its value isCLR_NONE, the arrow will not appear on the chart.

---

if manual - only write/borrow a ready-made script/indicator, which will catch this deal on history and show it with an icon

Thanks now I will try!!!!!
 
artborder:

Hello, here's a question:

When you run a programmatic search of charts, their subwindows, indicators in subwindows, you can find out the total number of indicators and then their names, parameters, etc.

Using ChartIndicatorsTotal, ChartIndicatorName etc.

How do I know the name of Expert Advisor running in this window also programmatically by ChartID?

Question on MT4

another question... How can I read MT4 log files? This code gives an error ... 5002

   string filename=TerminalPath() + "\\MQL4\\Logs\\20160219.log"; 
   int filehandle=FileOpen(filename,FILE_READ); 
   if(filehandle<0) 
     { 
      Print("Неудачная попытка открыть файл по абсолютному пути"); 
      Print("Код ошибки ",GetLastError()); 
     } 

    string str=FileReadString(filehandle); 
 
Can you please tell me what's the reason?HttpSendRequestW doesn't send request... GetLastError gives 0.

(the interesting thing is that WebRequest second version of it works... )

#property strict
#import "wininet.dll"
int InternetAttemptConnect(int x);
int InternetOpenW(string &sAgent,int lAccessType,string &sProxyName,string &sProxyBypass,int lFlags);
int InternetConnectW(int hInternet,string &szServerName,int nServerPort,string &lpszUsername,string &lpszPassword,int dwService,int dwFlags,int dwContext);
int HttpOpenRequestW(int hConnect,string &Verb,string &ObjectName,string &Version,string &Referer,string &AcceptTypes,uint dwFlags,int dwContext);
int HttpSendRequestW(int hRequest,string &lpszHeaders,int dwHeadersLength,uchar &lpOptional[],int dwOptionalLength);
int HttpQueryInfoW(int hRequest,int dwInfoLevel,int &lpvBuffer[],int &lpdwBufferLength,int &lpdwIndex);
int InternetOpenUrlW(int hInternet,string &lpszUrl,string &lpszHeaders,int dwHeadersLength,uint dwFlags,int dwContext);
int InternetReadFile(int hFile,uchar &sBuffer[],int lNumBytesToRead,int &lNumberOfBytesRead);
int InternetCloseHandle(int hInet);
#import

//Также для эстетики кода определим используемые имена констант из wininet.h.
#define  OPEN_TYPE_PRECONFIG     0           // использовать конфигурацию по умолчанию
#define  FLAG_KEEP_CONNECTION    0x00400000  // не разрывать соединение
#define  FLAG_PRAGMA_NOCACHE     0x00000100  // не кешировать страницу
#define  FLAG_RELOAD             0x80000000  // получать страницу с сервера при обращении к ней
#define  SERVICE_HTTP            3           // требуемый протокол
#define  INTERNET_FLAG_ASYNC     1

string            Host;       // имя хоста
int               Port;       // порт
int               Session;    // дескриптор сессии
int               Connect;    // дескриптор соединения

string acess_type;  // массив с данными для отправки POST-запросов 
uchar  data[];
string URL      = "http://ru.investing.com/earnings-calendar/Service/getCalendarFilteredData";
string Method   = "POST";
string ver_http = "HTTP/1.1";
string Refer    = "http://ru.investing.com/earnings-calendar/";

string HEADERS  = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"+"\n"+
                  "Content-Type: application/x-www-form-urlencoded"+"\n"+
                  "X-Requested-With: XMLHttpRequest"+"\n"+
                  "Connection: Close"+"\n";// сам запрос
  
string REQUEST_BODY ="pair_id=6408&action=searchStock";// сюда вписываем данные POST-запроса 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   StringToCharArray(REQUEST_BODY,data,0,StringLen(REQUEST_BODY),CP_ACP);
   
   OpenInet(URL,Port);
    
   int hRequest=HttpOpenRequestW(Connect, Method, URL, ver_http, Refer, acess_type, FLAG_KEEP_CONNECTION|FLAG_RELOAD|FLAG_PRAGMA_NOCACHE, 0); // создаем дескриптор запроса
   if(hRequest<=0)
   {
      Print("-Err OpenRequest");
      InternetCloseHandle(Connect);
      return(false);
   }  
  
    
   // отправили файл
   int hSend=HttpSendRequestW(hRequest,HEADERS,StringLen(HEADERS),data,ArraySize(data));
    
   if(hSend<=0)
   {
      Print("-Err SendRequest");
      InternetCloseHandle(hRequest);
      CloseInet();
   }


   return(INIT_SUCCEEDED);
}

//================== ФУНКЦИЯ ОТКРЫТИЯ / ЗАКРЫТИЯ ИНТЕРНЕТА ================================================================   
bool OpenInet(string aHost,int aPort)
{
   if (aHost=="") {Print("-Host is not specified"); return(false);}
   
   if (Session>0 || Connect>0) {CloseInet(); Print("+Open Inet...");} // если сессия была опеределена, то закрываем

   // Попытки создать подключение к Интернету   
   if (InternetAttemptConnect(0)!=0) {Print("-Err AttemptConnect"); return(false);} // если не удалось проверить имеющееся соединение с интернетом, то выходим
  
   string UserAgent="Mozilla"; string nill=""; 
   // Инициализирует приложение использует функции wininet  
   Session=InternetOpenW(UserAgent,OPEN_TYPE_PRECONFIG,nill,nill,0); // открываем сессию
   
   if (Session<=0) {Print("-Err create Session"); CloseInet(); return(false);} // если не смогли открыть сессию, то выходим

   Connect=InternetConnectW(Session,aHost,aPort,nill,nill,SERVICE_HTTP,0,0); // Открывает протокол передачи файлов (FTP) или http-сеанса для данного сайта.
   if (Connect<=0) {Print("-Err create Connect"); CloseInet();return(false);}
   
   Host=aHost; Port=aPort; // присвоение значений
   
   // все проверки завершились успешно
   return(true);
}
 
void CloseInet()
{
   Print("-Close Inet...");
   if(Session>0) InternetCloseHandle(Session); Session=-1;
   if(Connect>0) InternetCloseHandle(Connect); Connect=-1;
}
//========================================================================================================================= 
 
Money_Maker:
Can you please tell me what's wrong?HttpSendRequestW doesn't send request... GetLastError gives 0.

(The interesting thing is that WebRequest second version works ... )


If the second variant works, then there is a solution. So what is the problem?
 
Vinin:
If the second option works, there is a solution. So what's the problem?
the problem is that there will be so many links to enter into the terminal settings as allowed addresses( + I don't have the same computer...
is not an option at all(
 

Hello!

Can you please tell me how to find the beginning of the bar in the for loop, in general I need to look from the 1st bar to the 5th inclusive? (the current 0-bar is not counted).

for (int i=5; i<1; i++)

{

h = iHigh(Symbol(),tf,i);

......

Read the function for to understand only I can not. Help.

Regards!

 
Money_Maker:
Can you please tell me what's wrong?HttpSendRequestW doesn't send the request... GetLastError gives 0.

(The interesting thing is that WebRequest second version of it works... )


It's no longer the string that needs to be transferred, but the char buffer.

https://forum.mql4.com/ru/67441

 
Shargyn:

Hello!

Can you please tell me how to find the beginning of the bar in the for loop, in general, I need to look from the 1st bar to the 5th inclusive? (the current 0-bar is not counted)

Read the function for to understand only I can not. Help.

Regards!

with, to, what to do

for(int i=1;i<=5;i++)

or

for(int i=5;i>=1;i--)

But yes. The more logical thing to do during development was to make

with, what to do, to

for(int i=1;i++;i<=5)

 
#import "wininet.dll"
int HttpSendRequestW(int hRequest,char &lpszHeaders[],int dwHeadersLength,uchar &lpOptional[],int dwOptionalLength);
#import

char a[];
StringToCharArray(HEADERS,a);

int hSend=HttpSendRequestW(hRequest,a,StringLen(HEADERS),data,ArraySize(data));
Thank you for your answer, please tell me if I understood you correctly, do you mean like this?

so for some reason the result does not change either... (

another question: maybe you can programmatically add URLs to the allowed ones? (for example via macro substitution)
and frankly I don't want to use WebRequest because it's not asynchronous....
 
Money_Maker:
Thank you for the answer, please tell me if I understood you correctly, do you mean like this?

so for some reason the result does not change either... (

another question : maybe I can add the URLs to the allowed URLs programmatically ? (for example via macro substitution)
and frankly I don't want to use WebRequest because it's not asynchronous....

I think all thongs should be done like that.

The data about that list is stored in the terminal-config-experts folder

But it is very unclear there. It is necessary to ask the developers.