Strategy Desk backtesting results

Discussion in 'Automated Trading' started by Oliver84, Sep 5, 2009.

  1. Oliver - I don't know if this answers your question but here goes. You have to be careful about backtesting with SD. If your strat is working on the current bar, say Bar[Close,1], then you MUST buy and sell on close. If you use the previous bar, say Bar[Close,1,1] , then you must buy and sell on the open. If you buy on the open and use the current bar, it will give you a price before the trigger condition was met. This will always cause the backtesting results to be much better than they really are.
     
    #21     Sep 25, 2009
  2. Oliver84

    Oliver84

    Thanks for the tips. I did find the error in my formula. I was using the Bid function and did not know that if that's used in backtesting it uses the "current" bid because there is no bid history data. That's how my formula was seeing into the future and giving me great results.

    I've since modified it and took out the bid function. I'm getting really good entry point signals but having a hard time finding good exit triggers. I've been forward testing more now but if you guys can help me with my back testing, I'd much rather have that working because forwarding testing takes so long to get good enough data.

    How do you guys get your backtesting to match your forward testing results?
     
    #22     Sep 26, 2009
  3. borland

    borland

    Yes, good point, some quote functions, like the Bid do not work in backtesting.

    Also, some System functions do not work in backtesting. Hour, Minute, Second do not work; so instead use Bar[Hour, 5], Bar[Minute,5], and Bar[Second,5].

    Here’s my code for converting the daily stochastic to 5m bars..
    Code:
    { *** begin- BT Stochastic[StocK,14,3,1,D,0,$COMPX], 5m *** }
    (
      100
      *
      (
        Bar[Close,5,0,$COMPX] -
        (
          ( PriceRangeChannels[Lower,13,0,D,1,$COMPX] >= PriceRangeChannels[Lower,78,0,5,0,$COMPX] )
          * PriceRangeChannels[Lower,78,0,5,0,$COMPX]
          +
          ( PriceRangeChannels[Lower,78,0,D,1,$COMPX] < PriceRangeChannels[Lower,78,0,5,0,$COMPX] )
          * PriceRangeChannels[Lower,13,0,D,1,$COMPX]
        )
      )
      /
      (
        ( PriceRangeChannels[Upper,13,0,D,1,$COMPX] >= PriceRangeChannels[Upper,78,0,5,0,$COMPX] )
        * PriceRangeChannels[Upper,13,0,D,1,$COMPX]
        +
        ( PriceRangeChannels[Upper,13,0,D,1,$COMPX] < PriceRangeChannels[Upper,78,0,5,0,$COMPX] )
        * PriceRangeChannels[Upper,78,0,5,0,$COMPX]
        -
        ( PriceRangeChannels[Lower,13,0,D,1,$COMPX] >= PriceRangeChannels[Lower,78,0,5,0,$COMPX] )
        * PriceRangeChannels[Lower,78,0,5,0,$COMPX]
        -
        ( PriceRangeChannels[Lower,13,0,D,1,$COMPX] < PriceRangeChannels[Lower,78,0,5,0,$COMPX] )
        * PriceRangeChannels[Lower,13,0,D,1,$COMPX]
      )
    )
    { *** end- BT Stochastic[StocK,14,3,1,D,0,$COMPX, 5m *** }
    
    And converting a 26EMA on daily to 5m bars

    Code:
    { *** begin- BT ExpMovingAverage[EMA,Close,26,0,D,0,$COMPX], 5m *** }
    (
      (
        (
          Bar[Close,5,0,$COMPX]
          -
          ExpMovingAverage[EMA,Close,26,0,D,1,$COMPX]
        )
        *
        2
        /
        27
      )
      +
      ExpMovingAverage[EMA,Close,26,0,D,1,$COMPX]
    )
    { *** end- BT ExpMovingAverage[EMA,Close,26,0,D,0,$COMPX], 5m *** }
    
    Sad part of my initial trade strategy development is, I started writing my code for implementation, then realized I needed to convert it for backtesting. When all along I should have written it for both backtesting and implementation. That's what you could do, otherwise you have to convert it for backtesting.

    My code is so large that I choose to convert it for backtesting. So I have two sets of code for the same strategy, two for entry, two for exit.
     
    #23     Sep 26, 2009
  4. gains22

    gains22

    #24     Jan 30, 2010
  5. Oliver,

    The way I like to test my strategy is to use a "Live Replay" of pre-recorded information and fast forward it at 500x speed.

    I do this with NinjaTrader. Works great.
     
    #25     Feb 1, 2010
  6. I've seen this before myself many times when I've made mistakes.
    One of the other replies was spot on. Your doing something that is getting information from the future...Here's an example. Your doing
    something possibly on a daily basis and then your using possibly the following function somehow:

    PriceRangeChannels[Upper,1,0,M]

    Let's say that the backtesting is currently working on the date
    03/09/10, and let's say that on 03/22/10 is the highest price of the
    month. Well this function will return the 22nd's price rather than
    returning the highest price before 3/09.

    Hope this helps.
     
    #26     Sep 23, 2011
  7. The thread's old, and from 09 with the last post some time in 2010. Any reason to bring this up?
     
    #27     Sep 23, 2011