Announcement

Collapse
No announcement yet.

back testing formula - please help!!!

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

  • back testing formula - please help!!!

    Morning, wondered if you can help me. I want to back test trading a stock with the following rules....

    When (5 day simple mov aver) SMA5 becomes > SMA20, only when SMA20 > SMA200, then go long. When SMA5 becomes < SMA20 only when SMA20 > SMA200, then close this long position.

    When (5 day simple mov aver) SMA5 becomes < SMA20, only when SMA20 < SMA200, then go short. When SMA5 becomes > SMA20 only when SMA20 < SMA200, then close this short position.

  • #2
    jonathansilver
    You should be able to do that with the Formula Wizard which makes writing strategies of this kind a very easy task.
    For information on how to use the Formula Wizard click here. If at any point and time you get stuck with your efs post what you have done and someone may be able to help you out.
    Alex

    Comment


    • #3
      EFS Question

      Thanks for your help.

      I created a formula with SMA's which worked fine. However I then created an additional variable, ADX line > 25. When I ran the backtest, it threw out duff information. Please can you have a look at the formula and see what the error is.

      I want to back test trading a stock with the following rules....

      When (5 day simple mov aver) SMA5 becomes > SMA20, only when SMA20 > SMA200, only when ADX >25, then go long. When SMA5 becomes < SMA20 only when SMA20 > SMA200, only when ADX >25, then close this long position.

      When (5 day simple mov aver) SMA5 becomes < SMA20, only when SMA20 < SMA200, only when ADX >25, then go short. When SMA5 becomes > SMA20 only when SMA20 < SMA200, only when ADX >25, then close this short position.
      Attached Files

      Comment


      • #4
        SMA Cross Over

        Actually, just realised that my SMA formulas are completely wrong. There seems to be no option in the forumla wizard for cross overs!

        Comment


        • #5
          jonathansilver
          You may also want to review the conditions to Sell or Cover (Sets 2 and 4) because they may not trigger when you are expecting them to do so.
          Alex

          Comment


          • #6
            Alexis, there is no cross over option within the formula wizard? How do I do this? I cannot find any reference to do this within the esignal help files.

            Comment


            • #7
              jonathansilver
              In Sets1 and 3 you need to add a condition that defines where the 5 MA was in relation to the 20 MA at the prior bar (ie at Offset -1).
              So, for example, in Set 1 you will add a condition that is as follows



              Notice that I have added that the condition
              vSMA5.getValue(MAStudy.MA, -1) < vSMA20.getValue(MAStudy.MA, -1)
              ie at the prior bar the 5MA was below the 20MA thereby creating a crossover condition
              I also added a Strategy.isLong() == false condition to ensure that the command will be executed only if you are not already Long
              Alex

              Comment


              • #8
                Thanks. Thats amazing, but how do you enter the condition vSMA5.getValue(MAStudy.MA, -1) < vSMA20.getValue(MAStudy.MA, -1)

                Comment


                • #9
                  jonathansilver
                  When you select the study (or value) to use in the condition you apply the Offset to reference the appropriate bar.



                  Offset 0 is the current bar, Offset -1 is the prior bar, Offset -2 is two bars back, etc.
                  Alex

                  Comment


                  • #10
                    Thanks Alexis. Would you mind taking a quick look just to be sure I have programmed it right. I have attached the file. In particluar are sets 2 and 4 right?
                    Attached Files

                    Comment


                    • #11
                      jonathansilver
                      Attached is the corrected version. Compare it to yours and notice all the changes I have made.
                      Alex
                      Attached Files

                      Comment


                      • #12
                        Thank you!

                        Comment


                        • #13
                          Alexis,

                          I just backtested the formula on Vodafone.
                          When I checked the trades output on backtest against the chart, I noticed that there are some errors. For example, the backtest produces the following trades: -

                          Buy 07/10/2000
                          Sell 07/27/2000

                          However on 07/10/2000, the 5 and 20 day SMA were below the 200 day SMA, therefore the trade should never have happened!

                          Any ideas?

                          Thanks

                          Jonathan

                          Comment


                          • #14
                            jonathansilver
                            What is the symbol and how is the Time Template set (IOW how many days are you loading in the chart)?
                            Alex

                            Comment


                            • #15
                              Symbol is VOD-LON

                              Time Template is set to Equity RTH - West Coast

                              Comment

                              Working...
                              X