Announcement

Collapse
No announcement yet.

Backtesting

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

  • Backtesting

    I'm trying to figure out how to do this. The attched EFS is a simple strategy with two long triggers and two short triggers. The exit strat is the same for both longs and short. When f.ex. Long number 1 trigged, I dont want Long number 2 to be trigged while the Long 1 still is valid because that will give a double buy signal. I have tried different ways, but just cant get this to work the way I want. Anyone have suggestions, or know how to do this?
    Attached Files

  • #2
    Try this...

    you were testing for

    (strategy.isLong() == 0).. This is a BOOLEAN value (logical - T/F)

    So I changed your code to

    (strategy.isLong()) -- true
    (!strategy.isLong()) -- not true (false)
    Attached Files
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks

      Thanks alot Brad, its working, but I get very strange results running the backtest. I also wanted to change the Limit order to marketorder from next bars open, that also working. But there are still something very wierd with the testresults, ind I just cant find out whats causing this strange results. Attaced the file with the changes, can you please take a look, or run a backtest on this, and suggest what to do? Thanks in advanced.
      Attached Files

      Comment


      • #4
        well, I don't know what you want it to do (accomplish), but looking at your code here are some hints..

        line 29 : MADirection = vSMA5.getValue(MAStudy.MA) - vSMA5.getValue(MAStudy.MA,-1);

        This is the DIFFERENCE of the current MA5 and the last (previous). In the area where you test for entry conditions, you are checking for

        (MADirection > 1) &&

        one other thing is this MADirection is nothing more than a VALUE (like a filter). I don't know if this is how you intended it to be designed, so I thought I would ask?.

        In my opinion the logic of this is wrong. Unless you are trading something with really big ranges, the difference between the current MA and last MA will probably be LESS THAN 1 (in most cases).

        --------------------------------------------------------------------------

        The other thing is you might want to take a look at you EXITS (below). I think they kinda all look alike?? Are you sure this is what you intended??

        PHP Code:
                //Cover from longs    
                
        if (  (high(0) < high(-1)) &&
                      (
        Strategy.isLong()) ) {
                       
        Strategy.doSell("Lx"Strategy.LIMIT,Strategy.THISBARStrategy.DEFAULT, close());
                }
                
                if ( (
        high(0) < high(-1)) &&
                    (
        Strategy.isLong()) ) {
                    
        Strategy.doSell("Lx"Strategy.LIMIT,Strategy.THISBARStrategy.DEFAULT, close());
                 }


                
        //Cover from shorts
                
        if (
                    (
        high(0) < high(-1)) &&
                    (
        Strategy.isShort()) ) {
                    
        Strategy.doCover("Sx"Strategy.LIMIT,Strategy.THISBARStrategy.DEFAULT, close());
                    }
                
                if (
                    (
        high(0) < high(-1)) &&
                    (
        Strategy.isShort()) ) {
                    
        Strategy.doCover("Sx"Strategy.LIMIT,Strategy.THISBARStrategy.DEFAULT, close());
                    } 
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Thanks

          I have done the changes you suggested, also removed the MA diff, and instead using above/below the 5 SMA.
          Thing is that I'm still getting very strange results running the backtest function on this, f.ex, look at the attached picture, It enters a short trade 13.08.07 12:05, and exits at 20:50? Also attached the updated efs.
          Best regards
          Attached Files

          Comment


          • #6
            try this..

            Again. I don't know what you are trying to accomplish with this so it's hard for me to find the problems. Normally I would ask you to ILLUSTRATE the problem so I understand it completely.
            Attached Files
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment

            Working...
            X