how to write code that parse my json that I got with webrequest - page 2

 
Yeah, received empty data.
 
Caner Efe Altıntaş #:
Yeah, received empty data.

i see its a test site ...

Try this url

https://webhook.site/9102209a-06c1-4590-a7a5-d5f0a3493e4b
 

Received 4014 error;

Below my codes




#include "jason_with_search.mqh"


//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//---

    string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);

    string filename=terminal_data_path+"\\MQL5\\Files\\"+"fractals.csv";

    string cookie=NULL,headers;

    char   post['A'],result[];

    string url = "https://webhook.site/9102209a-06c1-4590-a7a5-d5f0a3493e4b";


      // Make a GET request to the webhook.site URL

    int res=WebRequest("GET",url,NULL,NULL,500,post,0,result,headers);

    

    // Print the JSON data

    Print("Web request result: ", res, ", error: #", (res == -1 ? GetLastError() : 0));

   string test_alert=CharArrayToString(result,0,ArraySize(result),CP_UTF8);

   Alert(test_alert);

   CJAVal loader;

   loader.Deserialize(test_alert,CP_UTF8);

   //you then go into the data like accessing arrays , but first for a test you output what the result is 

   bool am_i_testing=true;

   if(am_i_testing){

int f=FileOpen("Test.csv",FILE_WRITE|FILE_TXT);

FileWriteString(f,test_alert);

FileClose(f);     

}


 
Caner Efe Altıntaş #:

Received 4014 error;

Below my codes


you need to add the new url in the list of urls like the other one i think

So here is how you would get the name from that response :

#include "jason_with_search.mqh"

void OnStart()

  {

//---

    string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);

    string filename=terminal_data_path+"\\MQL5\\Files\\"+"fractals.csv";

    string cookie=NULL,headers;

    char   post['A'],result[];

    string url = "https://webhook.site/9102209a-06c1-4590-a7a5-d5f0a3493e4b";



      // Make a GET request to the webhook.site URL

    int res=WebRequest("GET",url,NULL,NULL,500,post,0,result,headers);

    

    // Print the JSON data

    Print("Web request result: ", res, ", error: #", (res == -1 ? GetLastError() : 0));

   string test_alert=CharArrayToString(result,0,ArraySize(result),CP_UTF8);

   Alert(test_alert);

   CJAVal loader;

   loader.Deserialize(test_alert,CP_UTF8);
   
   //now for instance to get the field "name" - i placed a "name" object in the json 
   Print("Name is "+loader["name"].ToStr());

   //you then go into the data like accessing arrays , but first for a test you output what the result is 

   bool am_i_testing=true;

   if(am_i_testing){

int f=FileOpen("Test.csv",FILE_WRITE|FILE_TXT);

FileWriteString(f,test_alert);

FileClose(f);     
}

}
 

here is how you can edit your url too to make it for json testing :

let me know when you are done so i close the rurl

 

Done, I received data by edit way.

My question, I have already data alerts below picture you can see, thank you

Files:
 
Caner Efe Altıntaş #:

Done, I received data by edit way.

My question, I have already data alerts below picture you can see, thank you

I see ,so you are sending that data to the webhook from Trading view and you want to read it on mt5

 

My current broker working with mt4 and which function can I receive the data?

 
yes I want to do what you said just in mt4
 
Caner Efe Altıntaş #:
yes I want to do what you said just in mt4

hmm if i'm not mistaken you'll need your own server for that .

However (i suppose) you could use "if this then that" , if the telegram actions allow sending a message to a bot and if the sender is not a bot itself . 

(it has webhooks too , i'll dust up my account and take a look , i had attempted this before)

Edit : its a bot that sends the messages and bots cannot read other bots posts so you will probably need a server .
Reason: