Announcement

Collapse
No announcement yet.

SMA of %k and %d lines

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

  • SMA of %k and %d lines

    Alexis - the study works fine, but there is one issue that i hope you can help with ...whenever we out a symbol in a chart, we have to "reload" the study. Any idea why ? i have pasted the study below. Thanks in advance !

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


    //{{EFSWizard_Declarations
    var vStoch14_5 = new StochStudy(14, 5, 2);
    var vSMA5_of_vStoch14_5 = new MAStudy(5, 0, vStoch14_5, StochStudy.SLOW, MAStudy.SIMPLE);
    var vSMA5_of_vStoch14_5_2 = new MAStudy(5, 0, vStoch14_5, StochStudy.FAST, 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("naq_STOCH_1");
    setCursorLabelName("X", 0);
    setCursorLabelName("Y", 1);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(2, 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(
    vSMA5_of_vStoch14_5.getValue(MAStudy.MA),
    vSMA5_of_vStoch14_5_2.getValue(MAStudy.MA)
    );
    //}}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

  • #2
    naq
    I am not sure I understand why you need to reload the efs.
    As far as I can see the efs appears to be working properly even when changing symbols or intervals
    Alex

    Comment


    • #3
      Hi Alex -

      Thanks again for your help in the past.
      I am hoping that we can take this to the next stage. I would like to modify this formula to do a back test. The decision rules would be:

      Sell Short - when the fast line (Y) crosses from above to below the slow line (X) ... but only when the Y line has a value of 80 or greater.
      Cover - when the Y line crosses above the X line.

      Go Long - when the fast line (Y) crosses from below to above the slow line (X) .. but only when Y has a value of less than 20.
      Cover - when the Y lone crosses below the X line.

      I have tried using the formula wizard but can't seem to make it work.

      Thanks in advance for all of your help, NAQ

      Comment

      Working...
      X