Announcement

Collapse
No announcement yet.

formatPriceNumber flawed?

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

  • formatPriceNumber flawed?

    Hi,

    I am seeing some weird results from formatPriceNumber.

    It seems when you first open esignal, and an efs I've written is already on the chart, while the bars are being loaded, the formatPriceNumber function returns an invalid result when called. Only once the chart is loaded does this function do what it is supposed to do.

    I'll post some short code to reproduce this problem when I have a sec, but wanted to see if anyone else is having this problem.

    Here is the procedure I am using which causes this issue

    I call a rounding routine which returns a valid result
    I call formatPriceNumber to convert this value into a value that can be displayed in drawtextXXX.

    When I first run esignal, and the above code in already on a chart, during the initialization, the call to formatPriceNumber results in a NULL value and a string size of 0.

    If I perform a refresh on the chart, the function call works correctly and the value is converted to a proper value to be displayed in drawtextXXX.

    I am speculating that the formatPriceNumber is relying on some internal variable to be set to a value that indicates how the output string should be handle--and when the program is first loaded and loading bars on the chart, this value is not initilized so formatPriceNumber is returning null.

    Where this causes problems is if you call drawtextXXX with the string to be displayed on the chart as null--it will generate an error. No problem we just catch that null before it gets there, and say don't display. while this works, it forces the user to manually refresh to chart to get the results, causing someone to thing the script is not working.

    Can one of the esignal guys comment on this function, and if this truely is the case? I am currently catching this issue and handling it accordingly, but it's causing my display of values to be different when esignal is first run than on subsequent calls to the efs, for example on the bonds chart it would normally be formatted 111'05, but not it's being formatted 111.0132 as I am not able to call formatPricenumber on the initial loading of esignal.

    Thanks

    Todd

  • #2
    Hm yeah.. the price formatting functions rely on the intial quote coming back to eSignal from the servers. If the EFS is called before this quote is returned from the servers, then the price formatting doesn't work.

    I'll see what we can do to fix this.

    thanks.

    Comment


    • #3
      I've just hit the same problem. Is there any suggested work around in the meantime? My code only prints numbers on the first pass through of the EFS and then the code is disabled so it always shows up as null for me.
      Standing on the shoulders of giants.

      Comment


      • #4
        Hello wildfiction,

        Sounds like you're describing a different problem, which may be related to your formula code. Please post a code example that illustrates the problem and I'll take a look.
        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,

          This is some sample code:

          var _init = true;

          function preMain() {
          setPriceStudy(true);
          setStudyTitle("example");
          setShowCursorLabel(false);
          setComputeOnClose();
          setShowTitleParameters(false);

          _init = true;
          }

          function main() {

          if ( getBarState() == BARSTATE_ALLBARS ) {
          return null;
          }

          if(_init)
          {
          _init = false;


          var showVal = 116.5
          var textToShow = formatPriceNumber(showVal);
          debugPrintln("showVal = " + showVal + " textToShow = " + textToShow);

          drawTextAbsolute(0, showVal, textToShow,
          Color.white, Color.blue, null, null, 10, "marker");
          }
          }


          And this is the output in the formula window: (Just discovered that you can't copy and paste from the formula window so I've attached an image of the output).

          The invalid 3rd param in drawTextAbsolute(...) I assume is because textToShow is null?

          Let me know what you think.
          Regards,
          Guy
          Attached Files
          Standing on the shoulders of giants.

          Comment


          • #6
            Guy
            FWIW here is what your code returns to the chart and Output Window when I run it. (note that I replaced 0 with 2 in drawTextAbsolute)
            Alex

            PS. Thank you for the compliment BTW.

            Comment


            • #7
              You're very welcome re the compliment - you're always very helpful in this forum.

              I've just tried doing exactly what you've done and this is what I get. Any ideas? (you can see my code change from 0 to 2 as you did and my other chart parameters seem to match yours)

              Standing on the shoulders of giants.

              Comment


              • #8
                Hello Wildfiction,

                Are you running the EOD version of eSignal? If so, that is the problem. There is a known bug with formatPriceNumber() that prevents that function from working properly on EOD version.
                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


                • #9
                  Jason,

                  I don't believe that I'm running the EOD version of eSignal - I'm running with real time charts.

                  However, I an not permissioned/entitled to minute/tick data on ZB and only recieve daily bars for ZB. Do you think that this is the problem or is this what you're talking about?

                  Perhaps Alexis can confirm that he can receive minute/tick data for ZB which I cannot...

                  Thanks
                  Guy
                  Standing on the shoulders of giants.

                  Comment


                  • #10
                    Hello Guy,

                    Yes, that is the problem. The formatPriceNumber() function uses some info from related quote. You need real time data for the ZB symbol for that function to work properly. Development is aware of this problem. Hopefully this will be fixed in the next version.
                    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

                    Working...
                    X