Announcement

Collapse
No announcement yet.

Can we now pass parameters in a button call?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can we now pass parameters in a button call?

    Is it now possible to pass a parameter (or two) in a button call ? I would like to be able to pass the currency symbol in the following call...


    drawTextAbsolute(117, 345, "Exit " + " @URL=EFS:callExitTrade", Color.white, Color.blue, butFlags, "Verdanna", 11, 341);

    I'm tracking more than one currency on one chart and don't want to have to have multiple copies of the exit function....or is there an alternative method that some brilliant programmer might have come up with?

    Thanks...

  • #2
    Hello Chris,

    Passing parameters to a function through the text string of a button click is not possible currently. The best thing I can suggest is to draw a button for each of the currency symbols you are trading. Set each button to run it's own function that sets the value of a global variable to it's corresponding symbol. Then use that global variable in your exit function. Then to exit a trade you would need to click two buttons to send the proper trade.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason,

      Couldn't you also set the function name to call as a string and use eval() in the drawTextXXX() line to have the strong evaluated to the correct function? Seems like that should work, and would limit the number of buttons also.


      if (xx == yy)
      sMyString = "@URL=EFS:My_ES_Function()";
      else
      sMyString = "@URL=EFS:My_NQ_Function()";

      drawTextAbsolute(117, 345, "Exit " + eval(sMyString), Color.white, Color.blue, butFlags, "Verdanna", 11, 341);



      Or something line that?

      G
      Garth

      Comment


      • #4
        Hi Garth,

        Yes, you could do that, but you would need a separate exit function for each symbol. We still need a method for setting the symbol in the myString variable, which is why I suggested the separate buttons for the symbols. It would be less code. Six of one and half dozen of the other right?
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Hi Jason,

          Unless you combine the two idea and your exit routines are just stubs that call the main exit routine with the correct symbol...that way you save code and buttons.

          I agree, the best solution is allowing paramter passing from buttons, but this sounds like a reasonable, and not too hard, work around.

          G
          Garth

          Comment


          • #6
            Hi Chris,

            Take a look at at the Trend Line Alert efs towards the start of this link. If you extract the button handler functions from this, I believe you could readily modify them to perform what you would like. If you take a look at the top of the efs
            PHP Code:
            var Text1 = new Array("Draw Line","Clear Line");
            var 
            Text2 = new Array("Price Magnet ON","Price Magnet OFF"); 
            You can add as many different actions for each of the buttons that you would like by adding additional strings to the array(s). Then code the respective actions for each of the strings in the button handlers. Then you can toggle through the different functions associated with each button with a right mouse click and execute with a left click.

            Comment


            • #7
              Hi Chris,

              If this works out for you, please post what you come up with, I believe it would be very helpful for others on the forum, plus I am interested as well .

              If you have problems, post what you have and either myself or others on the forum will help you make it work.

              Comment

              Working...
              X