Announcement

Collapse
No announcement yet.

setComputeOnClose(true); THISBAR vs. NEXTBAR

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

  • setComputeOnClose(true); THISBAR vs. NEXTBAR

    For a backtest formula with setComputeOnClose true, MARKET and NEXTBAR are used for entries, but for exits at a specific target or stop price (entry +/- increment) should THISBAR or NEXTBAR be used with Strategy.LIMIT? Depending on the use of THISBAR or NEXTBAR, so not to be forward-looking, when should the "if" statement conditions be looking at the previous bar(-1) vs. the current bar(0)? Was unable to find any documentation on this. Thanks.

  • #2
    Lancer
    Even if you have setComputeOnClose() in back testing you can use MARKET and THISBAR for the entries and set the if statement to look at the prior bar for the conditions to be true.
    As for the exits you can set the strategy to LIMIT and THISBAR with the if statement based on the current bar.
    See the attached as an example.
    Alex
    Attached Files

    Comment


    • #3
      It was the following post (item #3), and conflicting statements in other posts that raised the question. I'm still not completely clear on it. Would be good to have this addressed in EFS strategy documentation so there's no misunderstanding.



      Next.... the use of Strategy functions is critical to the outcome of your strategy's backtest.. I've learned three simple rules that I apply to all my systems...

      1. If you are entering on a limit price, you MUST verify the price has actually BREACHED the price you are trying to enter at before you execute the trade. Otherwise, your system will be skewed. Limit orders do not always fill when the market price touches your price level. It has to BREACH it.

      When using limit orders for a backtesting system, use Strategy.LIMIT, Strategy.THISBAR - and verify the price bar is within the range of your LIMIT price.

      2. If you are using a system that waits for a bar to finish forming, then executes trades, use Strategy.MARKET, Strategy.THISBAR. Now, there is a trick to accomplish this.. you have to check for the entry conditions starting at -1 bar (not 0 bar). This way, you are always checking the finished -1 bar and entering on the open of the 0 bar. If you check the 0 bar for entry conditions and enter on the 0 bar - then your screwed.

      3. If you are using setComputeOnClose(true), then you should be using Strategy.MARKET, Strategy.NEXTBAR. Because the setComputeOnClose() function causes the EFS to run at the END of any current bar, you have to use NEXTBAR for entries. If you are not using setComputeOnClose() - then choose #1 or #2.

      Now, there may be other instances when you have to alter these conditions, but for the most part, these are generally accepted rules.
      Last edited by Lancer; 01-18-2005, 05:04 PM.

      Comment


      • #4
        Lancer
        AFAIK setComputeOnClose() is redundant in back testing since the back tester computes only on completed bars irrespective.
        In the example I posted in my prior message you will see that the entry is set to MARKET and THISBAR and that once the condition on the prior bar returns true it will execute on the current bar.
        In the same efs you will also see that for the exit I verify that the limit price which is defined by the moving average has been breached by the Open of the current bar else I use the Open as the exit price thereby satisfying the condition at point 1 of the post you quote.
        Alex.

        Comment

        Working...
        X