Announcement

Collapse
No announcement yet.

Colored Horizontal Squares

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

  • Colored Horizontal Squares

    Hi,

    Is it possible in EFS to code an indicator study and have the results displayed in a subchart as a colored horizontal square - one per bar, and the color be based on the value of the indicator study? If so, can someone provide a coding sample?

    Thanks in advance for your help!

    Warmest Regards,

    Andy

  • #2
    // I used the Formula wizard and changed SetPriceStudy to false.{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vStoch14_1 = new StochStudy(14, 1, 3);
    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(false);
    setStudyTitle("horizbars");
    //}}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 (
    vStoch14_1.getValue(StochStudy.FAST) < 50
    ) 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(0, 0, Shape.SQUARE, "", Color.red, Shape.LEFT);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //}}EFSWizard_Actions

    Comment


    • #3
      Yes. You can draw lines/box sets using the "drawLineRelative()" function or you can use the setBarBgColor() to change the backgound shading on the chart or you could try to use the "SQUARE" graphic object in EFS.

      If you want to keep the graphics relative to price action and want to reset/clear any drawn object, it's probably better to stick with the graphics object for SQUARE or unique line draws to create a box.

      The only suggestion I can make is to setup an array for all the drawn sets or objects so you can try to control them better.

      edited : although. If you are looking for colored (shaded) boxes, then use setBarBgColor() with a control object.

      setBarBgColor(Color.green,0, 12, 13);

      // draw a green background between prices 12~13 on pane 0
      Last edited by Doji3333; 06-15-2010, 04:51 PM.
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Thank you Doji3333 and dloomis for your suggestions. I'll give it a try.

        Warmest Regards,

        Andy

        Comment

        Working...
        X