Announcement

Collapse
No announcement yet.

Help on EFS to measure angle of EMA

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

  • Help on EFS to measure angle of EMA

    I wanted to take the current bar value and subtract it from the last bars value. Then that number could then look up in a matching table what to display on the screen. This would show the degrees of the line.

    Table example

    Difference of 3 would display 3 degrees
    Difference of 7 would display 9 degrees
    I would fill in the rest.

    Display on chart Like this if
    {
    drawTextRelative(1, 80, "Sell right now @ " + close(), Color.black, Color.red, Text.FRAME | Text.RELATIVETOP | Text.BOLD, null, null, "OS");
    } else if {
    drawTextRelative(1, 20, "Buy right now @ " + close(), Color.black, Color.green, Text.BUTTON | Text.BOLD, null, null, "OB");
    }


    and so on. I would have to fill in correct values for EURO as one EFS, Russell as one EFS and Bond as one EFS. Once this is doe it never has to change.
    You know woodies rules. Never trade with a 34EMA with less then 15 degrees, and this has kept me out of al lot of chop.

    I noticed that the 34EMA attached was done in the wizard and wondering if you can figures out on the wizard if this is possible and if you could do it and I will do the tables of degrees of 0 degrees to 90.
    Below is the EFS which was made in the E Signal wizzard that this feature would be added to.

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


    //{{EFSWizard_Declarations

    var vEMA34_of_HLC3 = new MAStudy(34, 0, "HLC/3", MAStudy.EXPONENTIAL);
    var vLastAlert = -1;

    //}}EFSWizard_Declarations 12193


    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("34 EMA");
    setCursorLabelName("34 EMA", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarThickness(3, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_INSTANTCOLORLINE,0);
    //}}EFSWizard_PreMain 30539

    }

    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() > vEMA34_of_HLC3.getValue(MAStudy.MA)
    ) onAction1()
    //}}EFSWizard_Expression_1 9296

    //{{EFSWizard_Expression_2
    else if (
    close() < vEMA34_of_HLC3.getValue(MAStudy.MA)
    ) onAction2();
    //}}EFSWizard_Expression_2 11350

    //}}EFSWizard_Expressions 38428


    //{{EFSWizard_Return
    return vEMA34_of_HLC3.getValue(MAStudy.MA);
    //}}EFSWizard_Return 5919

    }

    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() {
    setBarFgColor(Color.aqua);
    if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1 24209

    //{{EFSWizard_Action_2
    function onAction2() {
    setBarFgColor(Color.maroon);
    if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2 22305

    //}}EFSWizard_Actions 67343

  • #2
    Not sure I understand..

    Do you want "actual degrees of slope" or just "the point difference from the past bar to the current bar"???

    What would the "lookup" function do....???

    I'll help if I can.

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      EMA degrees progress.

      The codeo or wizzzard is almost done. Another person figured out how to do this and I just filled in the value difference and degrees. The only thing that needs to be done is the value to show up in the window like a text box. It would say for example "30 degrees" When the angle is less then 15 degrees all of us stay out. So all should be complete except putting the degrees on the screen . Could you help me on that one since I am a trader and having trouble as a programmer.

      [email protected]. If you could send me your e mail or tel # it could speed this along.
      Thanks


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

      //two arrays that you will need to maintain. The first array (aValues) is the list of price differences. The second
      //array (aDegree) is the list of degrees that corresponds to the values. You must always maintain exactly the same
      //number of elements in each array. So, in the arrays below, a price difference <= 1.0 equates to a degrees value of 2,
      //a price difference <= 2 equates to a degrees value of 3, etc. etc.
      aValues = new Array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
      aDegree = new Array( 1, 3, 10, 20, 21,21,22, 23,23,23, 23, 25, 30, 32, 35, 35, 38, 39, 42, 45 );

      //{{EFSWizard_Declarations

      var vEMA34_of_HLC3 = new MAStudy(34, 0, "HLC/3", MAStudy.EXPONENTIAL);
      var vLastAlert = -1;

      //}}EFSWizard_Declarations 12193


      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("34 EMA");
      setCursorLabelName("34 EMA", 0);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarThickness(3, 0);
      setPlotType(PLOTTYPE_LINE, 0);
      setPlotType(PLOTTYPE_INSTANTCOLORLINE,0);
      //}}EFSWizard_PreMain 30539

      }

      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() > vEMA34_of_HLC3.getValue(MAStudy.MA)
      ) onAction1()
      //}}EFSWizard_Expression_1 9296

      //{{EFSWizard_Expression_2
      else if (
      close() < vEMA34_of_HLC3.getValue(MAStudy.MA)
      ) onAction2();
      //}}EFSWizard_Expression_2 11350

      //}}EFSWizard_Expressions 38428




      //get value of MA this bar
      nVal1 = vEMA34_of_HLC3.getValue(MAStudy.MA, 0 );
      //get value of MA last bar
      nVal2 = vEMA34_of_HLC3.getValue(MAStudy.MA, -1 );

      //calculate the difference between the two
      nDiff = nVal1 - nVal2;
      nSign = nDiff>=0 ? 1.0 : -1.0 ;
      nDiff = Math.abs( nDiff );

      //walk through list of values and convert to degrees
      nPlot=0;
      for ( x=0; x<aValues.length; x++ ) {
      if ( nDiff<=aValues[x] ) {
      nPlot = aDegree[x];
      break;
      }
      }

      //At this point, the variable 'nPlot' will contain the degrees value associated with the
      //price change of the MA over the last bar. 'nSign' will contain the sign of the value. So
      //the final value will always be nSign * nPlot. (eg., if nDegrees is 3 and nSign is -1.0 then the
      //final answer will be -1.0 * 3 which equals -3 degrees.

      //So, your code that uses the Degrees information would go here.



      //{{EFSWizard_Return
      return vEMA34_of_HLC3.getValue(MAStudy.MA);
      //}}EFSWizard_Return 5919

      }

      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() {
      setBarFgColor(Color.aqua);
      if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1 24209

      //{{EFSWizard_Action_2
      function onAction2() {
      setBarFgColor(Color.maroon);
      if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vLastAlert = 2;
      }
      //}}EFSWizard_Action_2 22305

      //}}EFSWizard_Actions 67343

      Comment


      • #4
        Formula Wizard on 34 EMA

        Hi:
        I am playing with Earl's 34 ema Formula in the wizard and my lack of experience is showing.
        I am getting a syntax error when I attempt to replace the 34 EMA with a 50 EMA.
        What I did:
        Go through the efs and change the 34 to 50.
        Then, I did a syntax check and I get an error in the formula down below when it refers back to the 34 EMA.
        Then, I attempted to go down to this section and manually change the 34EMA to a 50 EMA.
        My question:
        Why is this not working?
        (Does it not like me?)
        When I go through the Formula wizard, why can I not not see a reference to this section of code?
        I am attaching the efs
        Harndog
        Attached Files

        Comment


        • #5
          Harndog
          Open the efs with the Editor and replace vEMA34_of_HLC3 with vEMA50_of_HLC3 in lines 65 and 67
          Also, you can't use the Formula Wizard on that formula at this point.
          Alex

          Comment


          • #6
            I changed it and reposted, too many things changed for me to tell you exactly what happened
            Attached Files

            Comment

            Working...
            X