Announcement

Collapse
No announcement yet.

Yahoo - Stops & Targets in EFS strategies

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

  • Yahoo - Stops & Targets in EFS strategies

    I was trying to wright a strategy that would go long when price
    closes above MA +1 and short when close -1. I also wanted to set a 5
    point/dollar stop if the price goes against the position and the 25
    point/dollar target. I made the EFS using Formula Wizard but couldnt
    implement stop and the target. I would appreciate any help on this
    matter.
    Thank you.

  • #2
    I had to insert close()+5 for the stop by hand, but this is what I would have done.

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


    //{{EFSWizard_Declarations

    var vEMA10 = new MAStudy(10, 0, "Close", MAStudy.EXPONENTIAL);
    var vLastAlert = -1;

    //}}EFSWizard_Declarations 9951


    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("ma+/-");
    //}}EFSWizard_PreMain 6303

    }

    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 (
    vEMA10.getValue(MAStudy.MA) < close()-1
    ) onAction1();
    //}}EFSWizard_Expression_1 9191

    //}}EFSWizard_Expressions 20337


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return 2256

    }

    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) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    if (vLastAlert != 1) Strategy.setStop(close()+5);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1 26540

    //}}EFSWizard_Actions 34715

    Comment


    • #3
      Thank you David for your reply.
      I have fine tuned the EFS a little to be more like i wanted.
      Now when i back test it if the strategy goes short at bars close and the same bars high was more or equal to +5 then the strategy exits at the same bar.
      Example from back testing:
      Short 02/05/2003 14.00 $849.00 1 ($-5.00) $4.25 0.00%
      Cover Stop Order 02/05/2003 14.00 $854.00 1 ($-85.50) ($-6.25)

      Here is the formula , maybe i made a mistake somewhere if you can point it out to me.
      Thank you.


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


      //{{EFSWizard_Declarations

      var vEMA34 = new MAStudy(34, 0, "Close", MAStudy.EXPONENTIAL);
      var vLastAlert = -1;

      //}}EFSWizard_Declarations 10337


      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("ma+/-");
      setCursorLabelName("EMA", 0);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarFgColor(Color.blue, 0);
      setDefaultBarThickness(2, 0);
      setPlotType(PLOTTYPE_LINE, 0);
      //}}EFSWizard_PreMain 28973

      }

      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 (
      vEMA34.getValue(MAStudy.MA) > close()+1
      ) onAction1()
      //}}EFSWizard_Expression_1 9332

      //{{EFSWizard_Expression_2
      else if (
      vEMA34.getValue(MAStudy.MA) <= close()-1
      ) onAction2();
      //}}EFSWizard_Expression_2 10425

      //}}EFSWizard_Expressions 40847


      //{{EFSWizard_Return
      return vEMA34.getValue(MAStudy.MA);
      //}}EFSWizard_Return 5215

      }

      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) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      if (vLastAlert != 1) Strategy.setStop(close()+5);
      setPriceBarColor(Color.RGB(255,0,0));
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1 30640

      //{{EFSWizard_Action_2
      function onAction2() {
      setPriceBarColor(Color.RGB(0,255,0));
      if (vLastAlert != 2) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      if (vLastAlert != 2) Strategy.setStop(close()-5);
      vLastAlert = 2;
      }
      //}}EFSWizard_Action_2 31645

      //}}EFSWizard_Actions 81279

      Comment


      • #4
        I think you need to read

        http://share.esignal.com/download.js...er=&file=Guide To Developing eSignal Strategies.doc

        and check out the Market orders this bar parts, maybe some one else will explain how to enter mid bar, but I think there are some examples in the doc I refer to above

        Comment


        • #5
          that link got messed up in the cut and paste, you need to type all of the text into the address area, fyi

          Comment


          • #6


            is where tha doc lives

            and you need

            setColorPriceBars(true);

            in preMain() to get the colors to show on the bars.

            Comment


            • #7
              Thank you , was looking for some kinda guide to EFS for a while now. Your link didnt work so i did a serch at eSignal share and found two docs in eSignal Group - Docs section. This probably is the one.

              Comment

              Working...
              X