Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1296

 

Good day to all. Question about WebRequest function, when I send POST request it doesn't send array of data. On the server side I get " <WSGIRequest: POST '/'> ". Below is the code:

string headers=NULL;
   char   data[],result[];
   string result_headers;
   string url="http://127.0.0.1:8000";

   ResetLastError();
   string params = "email=app@exemple.com&account=56781234";
   StringToCharArray(params, data, 0, StringLen(params));
   //ArrayResize(data,StringToCharArray(params,data,0,WHOLE_ARRAY,CP_UTF8));
   Print("data: ", CharArrayToString(data));
   int res=WebRequest("GET", url, headers, 0, data, result, result_headers);

   if(res!=200)
     {
      Print("Ошибка передачи файла на сервер #"+(string)res+", LastError="+(string)GetLastError());
     }
   else
     {
      Print(ArraySize(result));
     }
 
Alexander Mikryukov:

Good day to all. Question about WebRequest function, when I send POST request it doesn't send array of data. On server side I get " <WSGIRequest: POST '/'> ". Below is the code:

So you have a GET, right? Here I am sending a json (MQL5). Everything works.

   char data[]; 
   ArrayResize(data, StringToCharArray(jv.Serialize(), data/*, 0, WHOLE_ARRAY*/)-1);
   
   
   char res_data[];
   string res_headers=NULL;
   int r=WebRequest("POST",m_uri, "Content-Type: application/json\r\n", 5000, data, res_data, res_headers);
   Print(__FUNCTION__+": web server response code: ",(string)r);
   if(r!=-1)
     {
      Print(__FUNCTION__+": JSON message sent: "+CharArrayToString(data));
      if(save_to_file)
        {
         string file_name=file_name_prefix+"_"+m_symbol+"_"+(string)m_magic_number+".csv";
         int file_handle=FileOpen(file_name,FILE_READ|FILE_WRITE|FILE_CSV);
         if(file_handle!=INVALID_HANDLE)
           {
            FileSeek(file_handle,0,SEEK_END);
            FileWriteString(file_handle,"\n"+CharArrayToString(data));
            FileClose(file_handle);
           }
        }
     }

p.s. What's with the stupid "good day" expression? Here, for example, is an article on this subject. Sorry for the flood :)

 

In reference:

datetime  iTime( 
   const string        symbol,          // символ 
   ENUM_TIMEFRAMES     timeframe,       // период 
   int                 shift            // сдвиг 
   );
In this code, shift is taken as the NUMBER of BARs relative to the current time.
The example here is:
 int bar_index=iBarShift(symbol,tf,time,exact); 
   
 datetime bar_time=iTime(symbol,tf,bar_index); 
The help specifies that iBarShift returns the bar index.

My understanding is that the number of bars and the bar index are different parameters.

I would understand it if the numbering of bars would start from the current time (current = 0).
But OnCalculate() outputs the bar index number from the beginning of the window history.

Can you please explain what I have got wrong?
Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
Документация по MQL5: Доступ к таймсериям и индикаторам / Bars
  • www.mql5.com
Bars - Доступ к таймсериям и индикаторам - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Found out for myself.

The iBarShift help is written in heresy.
The function returns not bar index in OnCalculate() sense,
, but bar offset, i.e. shift.

In Inquisition times, this would have been burned at the stake:)
Документация по MQL5: Доступ к таймсериям и индикаторам / iBarShift
Документация по MQL5: Доступ к таймсериям и индикаторам / iBarShift
  • www.mql5.com
iBarShift - Доступ к таймсериям и индикаторам - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
User_mt5:
Found out for myself.

The help for iBarShift is full of heresy.
The function returns not bar index in OnCalculate() sense,
but bar offset, i.e. shift.

In Inquisition times, this would have been burned at the stake:)

I'm no expert in all this.... But the very first candidate for the bonfire... is YOU. Before writing "such heresy", you should have read the documentation yourself...!

P.S. And figure out what, where and how...
 

Good health to all!

The question is simple and naive. I wrote an EA in Mql5. I want to use this algorithm to work with cryptocurrencies on the exchange, such as BitMex. I can not understand how to rewrite EA for this exchange in another language, it is better in C, because Mql5 seems to be similar to C.

 
Good afternoon, all. Can you please tell me if my account has been blocked. My analyst, who led me, told me to find a broker. I do not know a broker. What to do in this situation. The amount in the account was $500.
 
Evgen1504:
Good afternoon, all. Can you please tell me if my account has been blocked. My analyst, who led me, told me to find a broker. I do not know the broker. What to do in this situation. The amount in the account was $500.
You have been scammed, not 500.
 
Amon1953:

Good health to all!

The question is simple and naive. I wrote an EA in Mql5. I want to use this algorithm to work with cryptocurrencies on the exchange, such as BitMex. I cannot understand how to rewrite EA for this exchange in another language, it is better in C, because Mql5 seems to be similar to C.

You do not need to rewrite it. You may look for a broker who allows trading cryptocurrency in MQL5.
Just in case, look at MT5 / View / Symbols

 
Rost17:
This is a question for mql specialists. How do I change positions closing marks in Expert Advisors? I want to have a red arrow to the left on a Sell close and a blue arrow to the left on a Buy close. Then I would immediately see that it is not the opposite opening, but exactly the closing. I have had it in MT4 and did not know a problem. I would like to change it in MT5. Thank you in advance.

Search for or write your own function to display trades on the chart