Announcement

Collapse
No announcement yet.

How do you configure a button to call a library function?

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

  • How do you configure a button to call a library function?

    The following button code will work if the buyCallback function is in my script:
    drawTextPixel(300, 25, " Buy @URL=EFS:buyCallback", Color.teal , Color.white, Text.BUTTON | Text.RELATIVETOLEFT | Text.RELATIVETOTOP, "courier new", 12, 0);

    " Buy @URL=EFS:buyCallback"As mentioned above, this works when the function is copied into my script.
    " Buy @URL=EFS:LibEFSAT.buyCallback" Error Message: Failed to call 'LibEFSAT.buyCallback': function is not defined.
    " Buy @URL=LibEFSAT.buyCallback" Browser opens
    " Buy @URL=LibEFSAT.buyCallback()" Nothing happens

    var LibEFSAT = addLibrary("EFSATLib.efsLib"); // I have this as a global variable, so the call below
    works when called somewhere in main,
    LibEFSAT.buyCallback();


  • #2
    I found a workaround to my issue. All I had to do is to create a function in my script and have that function call the library function.
    function currentConnectionCalledBack(){
    LibEFSAT.PrintConnection(connection); // or var connection = Trade.getCurrentConnectionID(); LibEFSAT.PrintConnection(connection); // this function gets the connection anyhow.

    function currentConnectionCalledBack(){ // To use a paper trading connection.
    var connection = "eSignal Paper Trading";
    LibEFSAT.PrintConnection(connection);
    |
    Anyhow, by adding the library as shown above, I can do this to call any function in it from a button on the chart by holding the shift key down and clicking on the button...I thought that I'd add this in case somebody wasn't aware of the need to do this. Happy coding to all!!

    Comment

    Working...
    X