Announcement

Collapse
No announcement yet.

formatPriceNumber Need Help

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

  • formatPriceNumber Need Help

    Hi,

    I've used formatPriceNumber before to find highs and low over a span of bars, but I guess I really don't understand formatPriceNumber for what I need now. Especially the way it works with a series ... I think.

    I'm just trying to get the two digits to the left of the decimal place to print out next to it's horizontal line. In this case for a Bollinger Band.


    Thanks For Your Help ... Again !


    Heres my snippet of code

    // fox 2
    setPriceStudy(true);
    var bInit = false;

    debugClear() ;

    function main() {

    if ( bInit == false ) {
    B60U = upperBB(60,3);
    bInit = true;
    }

    B60Ug = B60U.getValue(0);
    drawLineRelative(0, B60Ug, 15, B60Ug, PS_SOLID, 3, Color.RGB(250, 0, 0),5);


    B60Uf = formatPriceNumber(B60Ug);

    debugPrintln(" B60Uf =: " + B60Uf); // shows equal to null

    B60Uz = B60Uf.length; // This line gets the error, has no properties

    B60Uw = B60Uf.substring(B60Uz,(B60Uz-2));

    drawTextRelative(15, B60Ug, B60Uw, Color.red,null,Text.VCENTER,"Calibri",10,1);

    }

  • #2
    fastflyer
    With regards to what the formatPriceNumber() function does see this article in the EFS KnowledgeBase
    As to your script replace formatPriceNumber(B60Ug) with parseInt(B60Ug).toString() and it should do what you described [see the EFS KnowledgeBase for the description of the functions used]
    BTW [as I have suggested to you also elsewhere] you should explicitly declare variables with a var statement as a matter of good programming practice
    Alex


    Originally posted by fastflyer View Post
    Hi,

    I've used formatPriceNumber before to find highs and low over a span of bars, but I guess I really don't understand formatPriceNumber for what I need now. Especially the way it works with a series ... I think.

    I'm just trying to get the two digits to the left of the decimal place to print out next to it's horizontal line. In this case for a Bollinger Band.


    Thanks For Your Help ... Again !


    Heres my snippet of code

    // fox 2
    setPriceStudy(true);
    var bInit = false;

    debugClear() ;

    function main() {

    if ( bInit == false ) {
    B60U = upperBB(60,3);
    bInit = true;
    }

    B60Ug = B60U.getValue(0);
    drawLineRelative(0, B60Ug, 15, B60Ug, PS_SOLID, 3, Color.RGB(250, 0, 0),5);


    B60Uf = formatPriceNumber(B60Ug);

    debugPrintln(" B60Uf =: " + B60Uf); // shows equal to null

    B60Uz = B60Uf.length; // This line gets the error, has no properties

    B60Uw = B60Uf.substring(B60Uz,(B60Uz-2));

    drawTextRelative(15, B60Ug, B60Uw, Color.red,null,Text.VCENTER,"Calibri",10,1);

    }

    Comment


    • #3
      Thank You Again Alexis,

      " [as I have suggested to you also elsewhere] " ... Doh !

      And also let me repeat, you are our hero !

      By the way, I did not receive an e mail alerting me to your reply this time. This is the first question I've submitted since the new " forum " has been instituted. If some one else has mentioned this, I'm a repeater.

      Very Best Regards,
      Glenn

      Comment


      • #4
        Glenn
        You are welcome
        Alex


        Originally posted by fastflyer View Post
        Thank You Again Alexis,

        " [as I have suggested to you also elsewhere] " ... Doh !

        And also let me repeat, you are our hero !

        By the way, I did not receive an e mail alerting me to your reply this time. This is the first question I've submitted since the new " forum " has been instituted. If some one else has mentioned this, I'm a repeater.

        Very Best Regards,
        Glenn

        Comment

        Working...
        X