fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Parse WebRequest response and store into Variables

    Questions & Answers
    3
    9
    4307
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      GSMtricks last edited by

      Hi all,

      I am trying to make a trading bot with Broker integration.
      Right now have Node.js local server which gets a request from MT5 and sends requests via API to Broker.
      Right now have a major problem to analyze responses.

      The question is:
      How i can store WebRequest response into variables?
      Here is an example of a response to my request:
      {"balance":5704.45,"currency":"USD","id":"548853a0-0bec-a46d-dc34-7cd3f9xxx","loginid":"VRTC15912xx"}

      Looking for a way to store array separated into the variables, like:
      balance=5700
      currency=USD
      id= etc,.

      Please advice.

      T 1 Reply Last reply Reply Quote 0
      • l'andorrà
        l'andorrà last edited by

        Wow. I lost my mind after the words 'broker integration'. I have no idea what is that. Could please explain a bit more? Just curious.

        (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

        (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

        (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

        1 Reply Last reply Reply Quote 0
        • T
          trader.philipps @GSMtricks last edited by

          @gsmtricks Interesting project you have. What you are looking for is a JSON deserializer. You may start here and follow the links.
          There seem to be a custom library that has to be included in your project in order to use it. Unfortunately that is beyond my esperiences with fxdreema.

          I like to share my knowledge, but expect the others to contribute as well.

          1 Reply Last reply Reply Quote 0
          • G
            GSMtricks last edited by

            Broker integration I do mean that I have NODE.js app which can connect to binary.com and open trades.
            This local APP can send answers from broker to MT and now i can save the WEBrequest answer into a variable as a text string. But this is not useful for me, I need to get the answer parsed

            1 Reply Last reply Reply Quote 0
            • G
              GSMtricks last edited by

              0_1569657142858_SharedScreenshot.jpg

              But this example can't compile.

              0_1569657211774_SharedScreenshot.jpg

              T 1 Reply Last reply Reply Quote 0
              • T
                trader.philipps @GSMtricks last edited by

                @gsmtricks Did you copy the mqh file in the include folder of your mt4 instance?
                Additionally set project properties to.point to your mt instance.

                I like to share my knowledge, but expect the others to contribute as well.

                1 Reply Last reply Reply Quote 0
                • G
                  GSMtricks last edited by

                  Did you copy the mqh file in the include folder of your mt4 instance?

                  • Yes, also just for test i have create some example:

                  //+------------------------------------------------------------------+
                  //| Test1.mq5 |
                  //| Copyright 2019, MetaQuotes Software Corp. |
                  //| https://www.mql5.com |
                  //+------------------------------------------------------------------+
                  #property copyright "Copyright 2019, MetaQuotes Software Corp."
                  #property link "https://www.mql5.com"
                  #property version "1.00"
                  //--- input parameters
                  #include <JAson.mqh>
                  input string data="dd";
                  //+------------------------------------------------------------------+
                  //| Expert initialization function |
                  //+------------------------------------------------------------------+
                  int OnInit()
                  {
                  //--- create timer
                  EventSetTimer(5);

                  //---
                  return(INIT_SUCCEEDED);
                  }
                  //+------------------------------------------------------------------+
                  //| Expert deinitialization function |
                  //+------------------------------------------------------------------+
                  void OnDeinit(const int reason)
                  {
                  //--- destroy timer
                  EventKillTimer();

                  }
                  //+------------------------------------------------------------------+
                  //| Expert tick function |
                  //+------------------------------------------------------------------+
                  void OnTick()
                  {
                  //---

                  }
                  //+------------------------------------------------------------------+
                  //| Timer function |
                  //+------------------------------------------------------------------+
                  void OnTimer()
                  {
                  // Object
                  CJAVal json;

                  // Load in and deserialize the data
                  json.Deserialize(data);

                  // Try to access the data elements
                  Alert(json["orderid"].ToInt());
                  Alert(json["ordercurrency"].ToStr());

                  }
                  //+------------------------------------------------------------------+

                  I can compile it and it works.

                  Additionally set project properties to.point to your mt instance.

                  • what do you mean? As I can see error comes from FxDremma.

                  I did another test:

                  1. Downloaded blank expert advisor in mq5 format generated by FxDremma
                  2. Opened it in editor - compile - works
                  3. Added same line of code: #include <JAson.mqh>
                  4. Compile - a lot of error and as a result - can't compile it.
                  T 1 Reply Last reply Reply Quote 0
                  • T
                    trader.philipps @GSMtricks last edited by

                    @gsmtricks I meant the global options in the project.

                    0_1569662933769_9c998695-7b8f-4407-a926-92dd0b0913c1-image.png

                    I like to share my knowledge, but expect the others to contribute as well.

                    G 1 Reply Last reply Reply Quote 0
                    • G
                      GSMtricks @trader.philipps last edited by

                      @trader-philipps
                      Yes, sure I have it done.
                      You can try your self. Open any Expert generated by FxDreema and try to add line:
                      #include <JAson.mqh>

                      You will see - no way to compile it after that.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post

                      Online Users

                      A
                      J
                      D
                      E

                      29
                      Online

                      146.7k
                      Users

                      22.4k
                      Topics

                      122.6k
                      Posts

                      Powered by NodeBB Forums | Contributors