fxDreema

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

    Combine variables

    Questions & Answers
    3
    5
    2015
    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 to all.
      Lets say i have in variable string = EURUSD ( changed dynamical )

      I want to draw a button with a text: Buy EURUSD, but seems thee is no way to do it, coz "Buy" is static and rest is in variable, but in button text field i can just write static text or use text from variable, is there any way to make it works? Maybe some tricks?

      1 Reply Last reply Reply Quote 0
      • M
        miro1360 last edited by miro1360

        you can combine string variables ...

        string var1 = "EURUSD"
        string var2 = "buy"
        string var3 = "price:"
        double var4 = "1.21212"
        string var5

        into custom code block write this:
        string var5 = var1 + " " + var2 + " " + var3 + " " + (string)var4;

        and result in var5 is: "EURUSD buy price: 1.21212"

        Between trading and gambling is a very small gap, be careful.

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

          In a text (string) field, when you want to use variables, add ""+ in the beginning and + "" at the end. Something like this:

          "" + "Buy " + MyVariable + ""
          

          By the way I didn't made this "hack" intentionally. Long time ago I just found out that it works this way and I was doing it like that since then. But if you are not doing it that way, it could not work properly. Make sure that you have ""+ in the beginning and + "" at the end.

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

            @fxdreema said in Combine variables:

            In a text (string) field, when you want to use variables, add ""+ in the beginning and + "" at the end. Something like this:

            "" + "Buy " + MyVariable + ""
            

            By the way I didn't made this "hack" intentionally. Long time ago I just found out that it works this way and I was doing it like that since then. But if you are not doing it that way, it could not work properly. Make sure that you have ""+ in the beginning and + "" at the end.

            I tried but not works for me.
            I have Variable: low_ask ( value for example inside is: BTCUSD )

            I created a Draw text, and put the code inside:

            "" + "Buy " + low_ask + ""
            

            When try to compile:
            'low_ask' - undeclared identifier

            I wanted to get:

            Buy BTCUSD
            

            But still not lucky on this.

            After some test i have more info, if

            "" + MyVariabe + ""
            

            is my CONSTANT - than it works, but it's not a constant - it is variable
            0_1526543615579_Sketch.png

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

              Yes, something doesn't work and I will check it. But you can better do it that way in this case:
              0_1526900090341_56544a4b-9362-41f8-a0ae-ee1d9db82fa1-image.png

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

              Online Users

              G
              M
              C
              E
              L
              K
              E
              S
              E
              P
              G
              R
              N
              S
              E
              E

              27
              Online

              146.7k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors