Announcement

Collapse
No announcement yet.

MA Strategy backtesting

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

  • MA Strategy backtesting

    In backtesting a simple MA crossover system, which is called Myfirststrategy from the EFS online library, the results were definitely odd.

    Not a single profitable trade. When looked at individual trades, there were winning trades that were reported as losing.

    Any help greatly appreciated. Thank you.

  • #2
    Hello WilliamV,

    When inquiring about a problem related to a specific formula its very helpful to see the code. Please post the formula you are using as an attachment.

    Based on the name of the formula you mentioned, it may only be an example formula and not one that you can expect to be a profitable strategy.

    As for the individual trades you are analyzing, it may be that you are not properly comparing the the results in the Strategy Analyzer with the corresponding bars in the chart. I have yet to see an erroneous trade in the Analyzer. To look into this further, please post some specific examples using some images of the report and corresponding chart. Once I have a copy of the formula you are using, I'll test it on my end and we'll get it sorted out.
    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
      HI Jason,

      Thanks for your response. I've attached the script with the corresponding trades.

      C:\Program Files\eSignal\Pages\IBMTrades.html
      Attached Files

      Comment


      • #4
        Hello WilliamV,

        Thank you for posing your code. I've tested your formula and it is properly sending the trade information according to your code logic to the Strategy Analyzer. The problem I see with your code logic revovles around the stop orders where you are passing the value of the moving average for the stop price. If you have a entry bar that has crossed the moving average but the moving average value does not fall inside the range of the bar the formula will still use the value of the moving average for the entry/exit price, which is not realistic. The Strategy Analyzer does not automatically check for this scenario for you. You have to incorporate some additional conditions and check to make sure that the stop value you pass to the Analyzer is a realistic price. In the case of a gap where the range of the bar is above the moving average, pass the open of that bar for the stop instead of the value of the moving average.
        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


        • #5
          What if the "stop" in the case is another crossover? MA1>MA2 buy, MA1<MA2 sell?

          What if graphically it is shown the MA's crossover multiple times yet it only generates two trades?

          Using sampleprofittarget.efs without targets with crossover in it's place. Including script below.

          BTW, I believe you are the developer of the script and for that I thank you.
          Attached Files

          Comment


          • #6
            WilliamV
            The problem is caused by the if (Strategy.isInTrade() == false) condition in line 84. I suspect that the original sample would exit trades once a target was reached and therefore would have periods in which that condition was false. In a stop and reverse strategy that condition is true only once ie at the first trade. That means that the strategy no longer evaluates for MA crosses from that point on.
            Remove the condition in line 84 and you should see the strategy execute on all crosses
            Alex

            Comment


            • #7
              That was the fix. Thanks again Alex!

              There are two outstanding issues:

              1) There are clearly trades that are profitable but yet are showing a negative return on the Analyzer.
              Ex:On 3/14/2005, Short IBM @$91.65, covering @$90.00, yet shows loss of $84.99

              2)I have to come up with additional conditions for equity spreads that have negative spread "price", since the MA's are also negative and the < sign triggers trades in the opposite way.

              Comment


              • #8
                WilliamV
                With regards to point 1) without knowing what MA1.efs and MA2.efs are and what interval you are using in the back test it is impossible to replicate the problem.
                Alex

                Comment


                • #9
                  Sorry about that. I'm using the hourly chart with the MA's being zero lag MA and kaufman kama MA.

                  Comment


                  • #10
                    WilliamV
                    Unfortunately that does not help as I don't have the zero lag MA and don't know which version of the KAMA you are using. You may need to post the efs(s) or the links to where they can be downloaded
                    Alex

                    Comment

                    Working...
                    X