Announcement

Collapse
No announcement yet.

formatPriceNumber()

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

  • #16
    I was suggesting you calc the len of the fractional part of the price to determine the number of digits past the decimal point.

    Comment


    • #17
      ok but that won't work as in the example I gave, e.g. price of 32 where symbol is displayed with 2 decimal places. I need to calculate the number of displayed decimal places for the symbol

      Comment


      • #18
        Hi bpschoch,

        Have you tried using typeof() to determine if it is a data type issue? Short of anything more substantive, I am tapped out. I believe Murphy is probably in cahoots with Peter Cottontail on this one. ;~) Hope everything works out.

        Cheers!

        Comment


        • #19
          e.g. price of 32

          I thought of that too, however if you use the suggestion I made you will have to keep track of the max number returned, that way if the security trades at 32, then 32.1 then 32.34 then only trades with a max of 2 decimals, you would quickly realize the number of decimals was 2.

          Comment


          • #20
            I think the thing to do is to wait till someone from esignal can chime in. These calculations are done at initialization so I only get 1 price. In the end formatPriceNumber should be working and consistently, perhaps there is something wrong with the install that isn't working. Wel''l see what they say.

            Comment


            • #21
              Hello Bernie,

              I've been testing the following code and haven't been able to reproduce a zero length string for fp.

              PHP Code:

              function preMain() {
                  
              setPriceStudy(true);
                  
              setStudyTitle("test");

              }

               
              function 
              main() {
                  var 
              nState getBarState();
                  var 
              sym getSymbol();
                  
                  if (
              nState == BARSTATE_ALLBARS) {
                      
              debugClear();
                      var 
              close();
                      var 
              fp formatPriceNumber(p);
                      var 
              intp p.toFixed(0);
                      var 
              dec fp.length intp.length// calculates number of dec pts in sym
                      
              if (fp.indexOf(".") >= 0dec -= 1;
                      
                      
              debugPrintln("dec: " dec);
                      
              debugPrintln("intp: " intp "  fp: " fp "  p: " p);
                  }
                  
                  return;

              The only thing I can think of codewise is that p is not getting set to a valid value before passing it to formatPriceNumber(). I would suggest applying some validation to p before allowing the script to continue.

              Try something like if (isNaN(p) || p <= 0 || p == null) return;
              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


              • #22
                Jason, I have an idea of what may be happening and it's a guess on how charting works. The other system (which doesn't work) is earl's who doesn't have interday stock but gets daily data for stocks (remember this works on my system ok). I suspect that formatPriceNumber uses a 'dictionary' that has data on how to format the symbol and that because he doesn't have intraday data, that dictionary is not loaded and therefore formatPriceNumber doesn't know how to format and then returns null. If that's the case then that dictionary should still be loaded

                Bernie

                Comment


                • #23
                  Hello Bernie,

                  So Earl is running this on Daily intervals only? I think you're on to something. I'll find out if this is supposed to work with EOD subscriptions.
                  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


                  • #24
                    Hello Bernie,

                    Your suspicion was pretty close. According to our development team, the formatPriceNumber() function does use some information sent with a quote record that may not be available in EOD versions. They are looking into it.
                    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


                    • #25
                      Yes I was able to duplicate it with the German Dax AX #F-DT which I don't subscribe to but do get a daily price and it fails there on my system also, so that's it.

                      Comment

                      Working...
                      X