Announcement

Collapse
No announcement yet.

Help needed

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

  • Help needed

    Hello,

    I'm novice in efs programmation and I need help concerning an indicator.
    First of all, here is the actual program:

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


    //{{EFSWizard_Declarations
    var vStoch5_1 = new StochStudy(5, 1, 3);
    var vStoch14_1 = new StochStudy(14, 1, 3);
    var vStoch45_1 = new StochStudy(45, 1, 14);
    var vStoch75_1 = new StochStudy(75, 1, 20);
    var vSMA9 = new MAStudy(9, 0, "Close", MAStudy.SIMPLE);
    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("STPMT");
    setCursorLabelName("STPMT", 0);
    setCursorLabelName("MovAV", 1);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    //}}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
    //}}EFSWizard_Expression_1

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return new Array(
    (4.1*vStoch5_1.getValue(StochStudy.FAST)+2.5*vStoc h14_1.getValue(StochStudy.FAST)+1*vStoch45_1.getVa lue(StochStudy.FAST)+4*vStoch75_1.getValue(StochSt udy.FAST))/11.6,
    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() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //}}EFSWizard_Actions



    OK, now I just want to add a simple 9-moving average of the constructed indicator (cfr Array of 2 values). How can this be done? I know this is surely quite simple but please help a

  • #2
    Re: Help needed

    Vermaut
    Given that the average of an equation is the same as the equation of the individual averages of its components (ie AVERAGE(a+b) is the same as AVERAGE(a)+AVERAGE(b)) and that the Slow Stochastic is none other than a simple moving average of the Fast Stochastic you can very easily create the average of the indicator by implementing a couple of changes and using some cut and paste.
    The first thing you need to do is change the third parameter of all the Stochastic studies and set it to 9 ie
    var vStoch5_1 = new StochStudy(5, 1, 9);
    var vStoch14_1 = new StochStudy(14, 1, 9);
    var vStoch...etc

    Then make a copy of the entire equation that calculates the indicator (in other words the first value of your return array) and paste it in the return array as the second value (currently this is a null). Now in this second equation that you just pasted replace each instance of StochStudy.FAST with StochStudy.SLOW ie
    (4.1*vStoch5_1.getValue(StochStudy.SLOW)+2.5*vStoc h14_1.getValue(StochStudy.SLOW)+ ...etc
    At this point you have essentially created a 9 period moving average of your indicator
    Alex


    Originally posted by Vermaut
    Hello,

    I'm novice in efs programmation and I need help concerning an indicator.
    First of all, here is the actual program:

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


    //{{EFSWizard_Declarations
    var vStoch5_1 = new StochStudy(5, 1, 3);
    var vStoch14_1 = new StochStudy(14, 1, 3);
    var vStoch45_1 = new StochStudy(45, 1, 14);
    var vStoch75_1 = new StochStudy(75, 1, 20);
    var vSMA9 = new MAStudy(9, 0, "Close", MAStudy.SIMPLE);
    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("STPMT");
    setCursorLabelName("STPMT", 0);
    setCursorLabelName("MovAV", 1);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    //}}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
    //}}EFSWizard_Expression_1

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return new Array(
    (4.1*vStoch5_1.getValue(StochStudy.FAST)+2.5*vStoc h14_1.getValue(StochStudy.FAST)+1*vStoch45_1.getVa lue(StochStudy.FAST)+4*vStoch75_1.getValue(StochSt udy.FAST))/11.6,
    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() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //}}EFSWizard_Actions



    OK, now I just want to add a simple 9-moving average of the constructed indicator (cfr Array of 2 values). How can this be done? I know this is surely quite simple but please help a

    Comment


    • #3
      ok

      THank you mery much.

      Comment


      • #4
        Re: ok

        Vermaut
        You are welcome
        Alex


        Originally posted by Vermaut
        THank you mery much.

        Comment

        Working...
        X