Announcement

Collapse
No announcement yet.

DrawShape not working *Newbie Question*

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

  • DrawShape not working *Newbie Question*

    This is my first attempt at EFS. I used the Wizard to generate some code. If the low of the current bar is lower than the low of the last three bars, I want to show a red dot below the bar.

    The code that the Wizard came up with only works on the last instance of this that occurs on the chart. How do I get it to work on EVERY instance?:

    PHP Code:
    //{{EFSWizard_Description
    //
    //    This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vRSI15 = new RSIStudy(15"Close");
    var 
    vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
       
    /**
        *  This function is called only once, before any of the bars are loaded.
        *  Place any study or EFS configuration commands here.
        */
    //{{EFSWizard_PreMain
        
    setPriceStudy(true);
        
    setStudyTitle("Above 70 RSI with low of 3 bars");
    //}}EFSWizard_PreMain

    }

    function 
    main() {
       
    /**
        *  The main() function is called once per bar on all previous bars, once per
        *  each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
        *  in your preMain(), it is also called on every tick.
        */

    //{{EFSWizard_Expressions
        //{{EFSWizard_Expression_1
            
    if (
                
    low() < low(-1) &&
                
    low() < low(-2) &&
                
    low() < low(-3)
            ) 
    onAction1();
        
    //}}EFSWizard_Expression_1
        
    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
        
    return null;
    //}}EFSWizard_Return

    }

    function 
    postMain() {
       
    /**
        *  The postMain() function is called only once, when the EFS is no longer used for
        *  the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
    }

    //{{EFSWizard_Actions
        //{{EFSWizard_Action_1
        
    function onAction1() {
            
    drawShapeRelative(0low(), Shape.CIRCLE""Color.RGB(155,0,0), Shape.BOTTOM"ALERT");
            
    vLastAlert 1;
        }
        
    //}}EFSWizard_Action_1
        
    //}}EFSWizard_Actions 
    Last edited by cashonly; 09-26-2005, 01:22 PM.

  • #2
    cashonly
    That is happening because every graphic object you are drawing on the chart has the same tagName ie "ALERT" which means that only the last one will be drawn on the chart while the other ones get removed as there can be only one graphic object per name.
    You need to add something else to the tagName that will make each object unique so that it does not get overwritten.
    The simplest solution is to add getCurrentBarCount() (which as the name implies is a bar counter) to the tagName. See the enclosed revision of your script
    Alex

    PHP Code:
    //{{EFSWizard_Description
    //
    //    This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vRSI15 = new RSIStudy(15"Close");
    var 
    vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
       
    /**
        *  This function is called only once, before any of the bars are loaded.
        *  Place any study or EFS configuration commands here.
        */
    //{{EFSWizard_PreMain
        
    setPriceStudy(true);
        
    setStudyTitle("Above 70 RSI with low of 3 bars");
    //}}EFSWizard_PreMain

    }

    function 
    main() {
       
    /**
        *  The main() function is called once per bar on all previous bars, once per
        *  each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
        *  in your preMain(), it is also called on every tick.
        */

    //{{EFSWizard_Expressions
        //{{EFSWizard_Expression_1
            
    if (
                
    low() < low(-1) &&
                
    low() < low(-2) &&
                
    low() < low(-3)
            ) 
    onAction1();
        
    //}}EFSWizard_Expression_1
        
    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
        
    return null;
    //}}EFSWizard_Return

    }

    function 
    postMain() {
       
    /**
        *  The postMain() function is called only once, when the EFS is no longer used for
        *  the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
    }

    //{{EFSWizard_Actions
        //{{EFSWizard_Action_1
        
    function onAction1() {
            
    drawShapeRelative(0low(), Shape.CIRCLE""Color.RGB(155,0,0), Shape.BOTTOM"ALERT"+getCurrentBarCount());
            
    vLastAlert 1;
        }
        
    //}}EFSWizard_Action_1
        
    //}}EFSWizard_Actions 

    Comment


    • #3
      Thank you Alexis!

      Comment


      • #4
        cashonly
        You are most welcome
        Alex

        Comment

        Working...
        X