Announcement

Collapse
No announcement yet.

formatPriceNumber()

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • formatPriceNumber()

    hi,

    I am trying to use formatPriceNumber() in my EFS, but I get a blank string when I use it on US #F, MSFT etc.

    How can I use this function properly?

    my line of code is

    debugPrint(close()+" "+formatPriceNumber(close())+"\n");

    and it does not seem to work well.

    thanks,

  • #2
    plucky
    Seems to be working here (see image).
    When you say it does not "work well" what reading are you actually getting?
    Alex

    Comment


    • #3
      thank you for your response,

      the code is:

      debugPrint(close()+" "+formatPriceNumber(close())+"XX\n");

      and I get

      "111.0938 XX"

      exactly as output.

      thanks,

      Comment


      • #4
        plucky
        I just used your same exact debug line and this is the output I am seeing
        Can you post the whole efs?
        Alex

        Comment


        • #5
          i've run into the same problem except that I have a situation where the the formatPriceNumber is failing on someone elses esignal installation (7.7) but not failing on mine which is also the same release. Both of us use the same efs. So I think there is an intermittant or installation dependant problem with the function

          Comment


          • #6
            bp

            What does failing mean to you?

            Comment


            • #7
              it returns a zero length string

              Comment


              • #8
                bpschoch
                Can you provide a sample of the script and details on what symbol it fails with so others can try it?
                Alex

                Comment


                • #9
                  Remember this works correctly on my system.
                  this is a code snipit:

                  sym = getSymbol();

                  p = close();
                  fp = formatPriceNumber(p);
                  intp = p.toFixed(0);
                  dec = fp.length - intp.length; // calculates number of dec pts in sym
                  if (fp.indexof(".") >= 0)
                  dec -= 1;

                  when it fails fp.length = 0 and fp = ""

                  on my system they are correct

                  Comment


                  • #10
                    Sorry forgot to add, when it fails, it seems to fail on stock symbols such as wmt, c, intc, etc

                    Comment


                    • #11
                      bpschoch,

                      What is the value of close() and the symbol (as you described, seems to be high volume)? I would recommend that you record those and all other variables associated with the function as well. I suspect it has something to do with the initial loading of the data.

                      I would also record getOldestBarIndex() at the time of the "failing" and also when all the bars have loaded. This is to see if there are multiple efs starts if the data is being received in chunks, potentially due to the persons internet connection.

                      Comment


                      • #12
                        In my javascript manual a bug is listed...

                        start.indexof(substring)

                        If START is gt the length of STRING, indexof() returns an empty string, rather than -1.

                        Not sure if this is your issue or not.

                        Comment


                        • #13
                          I ran some debugprints on the failing system and p=58.12 fp="" intp=58 fp.len=0 intp.len=2

                          Comment


                          • #14
                            Can you get a valid answer by calculating

                            the length of (p-intp)

                            Comment


                            • #15
                              not sure what you are asking, p-intp does calculate, the purpose of this code segment is to determine the number of decimal places used for the current symbol. The reason for using formatPriceNumber is to get all the decimal places expanded so if p = 32 and the symbol is 2 decimal places, the formatPriceNumber(p) = 32.00

                              Comment

                              Working...
                              X