Announcement

Collapse
No announcement yet.

Better fills in backtesting

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

  • Better fills in backtesting

    I have a concern re: the validity of my results from backtesting. I understand that only completed bars may be used (in backtesting), thus Strategy.MARKET = bar open, and Strategy.CLOSE = bar close.
    Is it possible to perform math operations on these 'types', i.e.
    var realLongFill = ((Strategy.CLOSE) - (Strategy.MARKET))/2 - Just as a better approximation, and then:

    setLimit(realLongFill);
    and then using Strategy.LIMIT for fill type?

    I've coded the above, and get no syntax errors, but I also don't get filled...

    In a nutshell, how can we get more realistic fills in the backtesting environment? Hopefully I'm missing something obvious here... Thanks for the help!!

  • #2
    dsmith1

    Is it possible to perform math operations on these 'types', i.e.
    var realLongFill = ((Strategy.CLOSE) - (Strategy.MARKET))/2
    It is not possible to use the strategy methods in that way.
    A simple solution to accomplish what you want could be to compute a 1 period moving average of (High+Low+Close)/3 eg
    var realLongFill = sma(1,hlc3());
    and then use that as the Limit price eg.
    Strategy.doLong("Long", Strategy.LIMIT, Strategy.THISBAR,Strategy.DEFAULT, realLongFill);
    Hope this helps
    Alex

    Comment


    • #3
      thx

      thx - got it to work - gives me much more realistic results. Using that '.MARKET' can really skew a system's results.

      Comment


      • #4
        dsmith1
        You are most welcome.
        Strategy.MARKET should be used only if one is entering a trade based on the conditions that exist at the prior bar.
        Alex

        Comment

        Working...
        X