Announcement

Collapse
No announcement yet.

Watchlist EFS not updating columns

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

  • Watchlist EFS not updating columns

    Hello,

    I have created a basic watch list EFS based on the Kraut_ColoredBarsIndWL.efs obtained from this thread.

    I can't work out why the two columns my script adds to the WL only show predominantly red dots.

    I would appreciate any guidance in correcting any errors.

    PHP Code:
    var bInit false;

    var 
    vMA_Fast null;
    var 
    vMA_Slow null;

    //********************************************************************************************
    function preMain() {
    //********************************************************************************************
                 
    setCursorLabelName("Range"0);
                 
    setCursorLabelName("Active"1);
    }
    //********************************************************************************************
    function main() {
    //********************************************************************************************  

        
    var range high(0) - low(0);
        var 
    range_1 high(-1) - low(-1);
        var 
    range_2 high(-2) - low(-2);

        var 
    vColor "";

        var 
    vMA_Slow
        
    var vMA_Fast

       
    if (!bInit)
        {

            
    vMA_Slow ema(34,close());
            
    vMA_Fast ema(15,close());


            
    bInit true;
        }  

        var 
    nMA_Fast vMA_Fast.getValue(0);
        var 
    nMA_Slow vMA_Slow.getValue(0);

        var 
    nMA_Fast_1 vMA_Fast.getValue(-1);
        var 
    nMA_Fast_2 vMA_Fast.getValue(-2);
        var 
    nMA_Fast_3 vMA_Fast.getValue(-3);

        var 
    nMA_Slow_1 vMA_Slow.getValue(-1);
        var 
    nMA_Slow_2 vMA_Slow.getValue(-2);
        var 
    nMA_Slow_3 vMA_Slow.getValue(-3);


    //    if (nBarState == BARSTATE_CURRENTBAR)
    //    {
            
    if (range &gtrange_1 &&amprange_1 &gtrange_2)
            {
                
    setBarBgColor(Color.green,0);
                
    vColor "GREEN"
            
    }
            else
            {
                
    setBarBgColor(Color.blue,0);
                
    vColor "BLUE"  
            
    }

    //    }  

        
    if (nMA_Fast &gtnMA_Fast_1 &&ampnMA_Fast_1 &gtnMA_Fast_2 &&ampnMA_Fast_2 &gtnMA_Fast_3)
        {
            
    setBarBgColor(Color.green,1);
            
    vColor "GREEN"  
        
    }
        else
        {
            
    setBarBgColor(Color.red,1);
            
    vColor "RED"  

        
    }


        return Array(
    nMA_FastvColour);



    Thank you
    Mark

  • #2
    After some more debugging, problem seemed to be around the creation of the MAs.
    1. Changed the declaration of vMA_Fast and vMA_Slow by assigning both to zero.
    2. Changed !binit to binit == false
    3. Fixed spelling errors in return statement.

    Columns changing as expected now.

    Comment


    • #3
      The main issue I see is you're redeclaring vMA_Slow and vMA_Fast within main() which shadows the global variables you already assigned. You don't need to assign these to 0 you just need to make sure the right ones are being used.

      Comment

      Working...
      X