Announcement

Collapse
No announcement yet.

Need Help with EFS

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

  • Need Help with EFS

    Could someone check out the enclosed EFS. Syntax checks but nothings comes up on chart.
    Thanks...
    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    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("Volume Reversal 2 Days AGO");
    //}}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 (close() <= high()+low()/2 &&
    volume() >= volume(-2)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    close() >= high()+low()/2 &&
    volume() >= volume(-2)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}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() {
    if (vLastAlert != 1) drawTextRelative(0, high(), "Sell", Color.red, null, Text.BOTTOM|Text.CENTER|Text.BOLD, "dungeon", 13);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawTextRelative(0, low(), "Buy", Color.black, null, Text.TOP|Text.CENTER|Text.BOLD, "dungeon", 12);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

  • #2
    Re: Need Help with EFS

    Greg
    If [as I am assuming] your intention is to calculate the sum of the High plus the Low and divide the result of that by 2 then the equation high()+low()/2 is written incorrectly.
    As is the value returned by the equation is that of the High plus the result of the Low divided by 2 (divisions and multiplications are performed before additions and subtractions) so you need to enclose high()+low() in parenthesis to perform the calculations in the desired order (anything in parenthesis is done before divisions and multiplications)
    Alex


    Originally posted by gwika
    Could someone check out the enclosed EFS. Syntax checks but nothings comes up on chart.
    Thanks...
    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    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("Volume Reversal 2 Days AGO");
    //}}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 (close() <= high()+low()/2 &&
    volume() >= volume(-2)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    close() >= high()+low()/2 &&
    volume() >= volume(-2)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}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() {
    if (vLastAlert != 1) drawTextRelative(0, high(), "Sell", Color.red, null, Text.BOTTOM|Text.CENTER|Text.BOLD, "dungeon", 13);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawTextRelative(0, low(), "Buy", Color.black, null, Text.TOP|Text.CENTER|Text.BOLD, "dungeon", 12);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

    Comment

    Working...
    X