fxDreema

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

    How to make Terminate function reference the current symbol

    Questions & Answers
    2
    5
    1620
    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.
    • J
      JamesDaly last edited by

      Re: Alert Messages

      Hi

      Im trying to get the Terminate function to reference the current symbol iv tried a string variable but cant get it too work.

      i would also like it to reference the alert message in the terminate terminal aswel

      something like

      USDZAR has terminated due to "1 of 3 custom messages from alert"

      Please advise i'm not technical so need it step by step (Sorry)

      0_1540393480986_terminate function.PNG

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        This is a string input, and in the code all strings are put between " like this:

        "this is my string"
        

        As you can see there are no " in the input fields, they are added later. But they will be added anyway, and everything you write there is considered a string, just a text.

        "Symbol()"
        

        But you can trick it. Add "" + in the beginning and + "" at the end

        "" + Symbol() + ""
        
        1 Reply Last reply Reply Quote 0
        • J
          JamesDaly last edited by

          Thanks this worked but now how do i get it to terminate with a custom message from the other blocks.

          should i just create multiple terminate functions with each message? will that work?

          Really appreciate the quick response.

          0_1540554425920_Capture.PNG

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            Something doesn't look good. See... in MQL and in every programming language, we define strings (text) with those symbols - either " or ', or even `. Depends on the language. In MQL4 we use ". So we can have:

            int integerValue = 123;
            double doubleValue = 0.123;
            string stringValue = "This is text";
            

            You can add two numbers easily, like we do it in the calculator:

            someIntegerValue = 123 + 456 + 789;
            

            And we can concatenate strings in a similar way:

            someStringValue = "Hello" + ", " + "World" + "!";
            

            You can see that + are used, but we are working with strings here. And the result is Hello, World!

            In fxDreema this "Message" field is a string field, but you don't need to write those ", they are automatically added later. This means that whatever you write, it will be a string. Write Symbol() and you will see text that says Symbol(), this will not be treated as a function.

            By adding "" + and + "", you trick fxDreema a little bit, and you can write MQL4 code between those. If you can see at the output source code, you can probably better understand what is going on. But why double " and then +, and then + and again ""... it doesn't matter, just accept that it works that way. Use these when you want to put functions and other MQL4 stuff between them, but keep them at the beginning and at the end. This syntax of triple quotes - "" " - is not valid. Do this:

            "" + Symbol() + " 18-Divergence detected or 17 2 losses detected or.." + ""
            

            Again, imagine that "" + and +"" are there only to do some trick, don't look at them as a syntax that is correct. They must be there, otherwise the trick would not work... I think. But what is between them should be correct MQL4 code.

            1 Reply Last reply Reply Quote 0
            • J
              JamesDaly last edited by

              @fxdreema said in How to make Terminate function reference the current symbol:

              ick fxDreema a little bit, and you can write MQL4 code between those. If you can see at the output source code, you can probably better understand what is going on. But why double " and then +, and then + and again ""... it doesn't matter, just accept that it works that way. Use these when you want to put functions and other MQL4 stuff between them, but keep them at the beginning and at the

              Thank you for taking your time in answering my question. That was thorough 🙂

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

              Online Users

              C
              M
              O
              H
              F
              H
              M

              10
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors