Announcement

Collapse
No announcement yet.

Backtesting Intrabar/ Entry Stops

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

  • Backtesting Intrabar/ Entry Stops

    Has anyone been using/developing a trading system for backtesting that is based on intrabar data?

    How do you simulate entry stops? I tried to do so using high/low data but I ended up getting very problematic results.

    Mark

  • #2
    difficult...

    This is difficult because you don't really know where the price was within the bar.

    You could try to create your system using 1 minute charts and allow for slippage. This might be a better way for you to accomplish your task.

    Another thing you could do is determine the entry conditional values and try to estimate the portion of the bar that would be missed...

    For example, if you were using a Sto crossover, you might determine the range of the STO values at the close of the bar (say %k = 22.5 and %d = 18.75), compared to the previous bars Sto values (say %k = 16.5 and %d = 19.25). You could extimate the Sto crossing point by using the following code...

    CalcIntersect(LastStoK, CurrentStoK, LastStoD, CurrentStoD, 1=bullish/-1=bearish)

    PHP Code:
    function CalcIntersect(a1b1a2b2type)
    {
      var 
    i
      
    var Periods 40;
      var 
    Line1Diff = (b1-a1)/Periods;
      var 
    Line2Diff = (b2-a2)/Periods;
      

       var 
    TLine1Start a1+Line1Diff;
       var 
    TLine2Start a2+Line2Diff;

      if (
    type == 1//  Bullish
      
    {
        while (
    TLine1Start TLine2Start) {
           
    TLine1Start += Line1Diff;
           
    TLine2Start += Line2Diff;
        }
      }
      if (
    type == -1//  Bearish
      
    {
        while (
    TLine1Start TLine2Start) {
           
    TLine1Start += Line1Diff;
           
    TLine2Start += Line2Diff;
        }
      }
        return (
    TLine1Start+TLine2Start)/2

    Lets say the intersection point was at 19.03.

    Now you could take the current StoK-lastStoK = give you a range. (this = 6.0.)

    Now take the Current StoK - the intersect point (this = 3.47)

    Now take 3.47 / 6.0 = 0.5783;

    Thus, you could estimate that you got filled at 0.5783 of the current bar's range. Of course you would have to round this value to the nearest actual value.

    Hope this helps..

    Brad
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X