Announcement

Collapse
No announcement yet.

Problem with setBarBgColor

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

  • Problem with setBarBgColor

    The return value will show correctly in the Data window but seems to be a problem with scaling on the subchart and reset scale doesn't fix the problem. On the normal output (variation 1) the values display two decimal places. If I add to.Fixed(0) it colors the whole bar and loses its y-scale the same as variation 2.

    Code:
        if (nMFI_Chaikin < 0 ) {
            setBarBgColor(Color.RGB(255,160,160), 0, nMFI_Chaikin, 0);
    
        } else {
            setBarBgColor(Color.RGB(160,255,160), 0, 0, nMFI_Chaikin );
        }
    // return variation 1 -  works properly if toFixed not used
        //return Math.round(nMFI_Chaikin);
    // Return variation 2  - colors the whole bar
        var vMF = (nMFI_Chaikin/1000000).toFixed(1);
        return(vMF);
    Click image for larger version

Name:	image20140204092444.png
Views:	1
Size:	19.1 KB
ID:	246941

  • #2
    pj909
    The toFixed() method returns a string (see this article in the EFS KnowledgeBase) which cannot be plotted on a chart so you need to convert the value back to a number. Search the forum and you will find examples of this as the topic has been covered before.
    That said you can control the number of decimals displayed directly from the Edit Study dialog without the need of any efs coding
    Alex


    Originally posted by pj909 View Post
    The return value will show correctly in the Data window but seems to be a problem with scaling on the subchart and reset scale doesn't fix the problem. On the normal output (variation 1) the values display two decimal places. If I add to.Fixed(0) it colors the whole bar and loses its y-scale the same as variation 2.

    Code:
        if (nMFI_Chaikin < 0 ) {
            setBarBgColor(Color.RGB(255,160,160), 0, nMFI_Chaikin, 0);
    
        } else {
            setBarBgColor(Color.RGB(160,255,160), 0, 0, nMFI_Chaikin );
        }
    // return variation 1 -  works properly if toFixed not used
        //return Math.round(nMFI_Chaikin);
    // Return variation 2  - colors the whole bar
        var vMF = (nMFI_Chaikin/1000000).toFixed(1);
        return(vMF);
    [ATTACH=CONFIG]16664[/ATTACH]

    Comment

    Working...
    X