Announcement

Collapse
No announcement yet.

Very simple reqest

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

  • Very simple reqest

    I am looking for moving average crossover strategy plus other indicator condition - such as rsi above 50 etc.

    something like that :

    if ma85>ema20 go long
    exit if stoch <60

    opposite by short

    I searched but still didnt find.

    can someone help me ?
    Last edited by pilpilonim; 11-19-2004, 08:39 AM.

  • #2
    Hello pilpilonim,

    Formulas structured around our builtin studies such as moving averages, RSI, Stochastics etc can be created through our Formula Wizard (Tools-->EFS). I would encourage you to read through our Formula Wizard Guide to learn more about it.

    You should be able to find many studies here in the forums as well. What search phrases did you use in your searches? If you search on "moving AND average AND cross* " you should find well over 100 posts containing those three keywords.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      It isn't working.

      I made the code but the trades are not met with thema crossover condition.

      the instrument is $dxc and the interval is 10 minutes.

      the backtest log says the first trade was at 17:40 08/06/04 while the conidition met accroding was at 13:20 08/06/04.
      plus there are several unexplained more buys at 17:50 and 18:00 08/06/04.

      I couldn't able to attach the log trades because esignal doesn't accept html files so i copied it :

      1 Buy 06/08/2004 17.40 $88.47
      Sell 06/10/2004 17.30
      2 Buy 06/08/2004 17.50
      Sell 06/10/2004 17.30 $89.33 100
      3 Buy 06/08/2004 18.00 $88.48
      Sell 06/10/2004 17.30


      the code :

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


      //{{EFSWizard_Declarations

      var vSMA8 = new MAStudy(8, 0, "Close", MAStudy.SIMPLE );
      var vSMA34 = new MAStudy(34, 0, "Close", MAStudy.SIMPLE);
      var vLastAlert = -1;

      //}}EFSWizard_Declarations 17496


      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("test");
      setCursorLabelName("ma34", 0);
      setCursorLabelName("ma8", 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 49797

      }

      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 (
      vSMA8.getValue(MAStudy.MA)+0.03 < vSMA34.getValue(MAStudy.MA)
      ) onAction1()
      //}}EFSWizard_Expression_1 11704

      //{{EFSWizard_Expression_2
      else if (
      vSMA8.getValue(MAStudy.MA) > vSMA34.getValue(MAStudy.MA)+0.03
      ) onAction2();
      //}}EFSWizard_Expression_2 14355

      //}}EFSWizard_Expressions 45071


      //{{EFSWizard_Return
      return new Array(
      vSMA8.getValue(MAStudy.MA),
      vSMA34.getValue(MAStudy.MA)
      );
      //}}EFSWizard_Return 12730

      }

      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() {
      Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1 15801

      //{{EFSWizard_Action_2
      function onAction2() {
      Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vLastAlert = 2;
      }
      //}}EFSWizard_Action_2 16996

      //}}EFSWizard_Actions 49692
      Attached Files
      Last edited by pilpilonim; 11-20-2004, 12:01 PM.

      Comment


      • #4
        pilpilonim
        It actually is working but the conditions are set incorrectly.
        As it is now it will go Long (or Short) on every bar where the shorter moving average is above/below the longer moving average



        Notice that in your conditions you have it set to go Short everytime the vSMA8 is below the vSMA34. This means that it will keep on compounding trades so long as that condition is true. You have three solutions available to fix this issue.
        The first one is to add a condition that checks if the strategy is not already Long or Short



        Once the system goes Short Strategy.isShort() will return true hence the conditional statement will be false and further commands to go Short are not triggered.
        Another solution is to set the command to execute only the first time



        In this case the Formula Wizard sets a flag that changes state when the command is executed.
        An alternative is to set the conditions in such a way as to be unique.



        Here I have added a condition that requires the vSMA8 to be above or equal the vSMA34 at the prior bar (determined by the -1 in vSMA8.getValue(MAStudy.MA, -1)). Notice also that I have now changed the Strategy.doShort() command to execute everytime because the condition is true only on the first bar when the averages cross.
        You would then need to replicate the same conditions for the Long side.
        Hope this helps
        Alex

        Comment


        • #5
          I felt comfortable with the first time solution so I changed the formula.
          but still not working well - what did I do wrong ?
          Attached Files

          Comment


          • #6
            pilpilonim
            Looks like you reversed the conditions and are going Long when you are supposed to go Short and vice versa. Try inverting the <> operators in Sets 1 and 2.
            Alex

            Comment


            • #7
              thanx alex.


              Is it possible to add a additional condition says if trix14>0 then go long ?

              Comment


              • #8
                pilpilonim
                It can be done but probably not with the Formula Wizard.
                With the Editor you would have to either compute the trix in the same efs or use call() or callFunction() to retrieve those values from another efs that calculates the trix.
                Alex

                Comment


                • #9
                  Is it complicated to compute the trix in the same efs and add the condition ?

                  Comment


                  • #10
                    pilpilonim
                    I don't have the formula that computes the trix available off hand so I would not know. Run a Search for trix to see if an efs is already available and at that point we can evaluate the situation
                    Alex

                    Comment


                    • #11
                      here u go - alexis.

                      appreciate your help.
                      Attached Files

                      Comment


                      • #12
                        pilpilonim
                        You may want to use the attached revision of the trix.efs you posted.
                        In real time that one will return values that are slightly off. You can verify this by reloading your version of the efs after it has been running for a while and you should see the plot readjust itself
                        Alex
                        Attached Files

                        Comment


                        • #13
                          hmmm - i m not sure i undersatnd you.

                          u were mentioning that the trix u uploaded suits more than mine.
                          thats ok but how can I combine this trix in my startegy ?

                          Comment


                          • #14
                            pilpilonim
                            The attached efs merges trix2.efs and test3.efs and includes the trix in the conditions to go long/short.
                            Note that at this point you can no longer use the Formula Wizard to edit this efs.
                            For information on how to write or edit indicators and strategies see the Guide to Developing eSignal Indicators and the Guide to Developing eSignal Strategies that are available in the EFS KnowledgeBase
                            Alex
                            Attached Files

                            Comment


                            • #15
                              Alexis ,

                              no words to express my thanking.

                              all the best,
                              pilpilonim

                              Comment

                              Working...
                              X