Back Testing Accuracy with OHLC data

Discussion in 'Strategy Building' started by SimpleMeLike, Feb 23, 2017.

  1. Turveyd

    Turveyd

    As long as you look at the previous 3 OHLC data bars when the new bar opens and in that instant get the software to make a decision then it'll be accurate.

    If your acting on the current open bars then it's not accurate as you already know the HLC parts which is an edge and therefore cheating.
     
    #11     Feb 24, 2017
  2. Thanks Turveyd for response,

    Why do I need to look at the previous 3 OHLC data bars?

    And what do you mean by cheating?

    Thanks,
     
    #12     Feb 24, 2017
  3. For back-testing, you begin at some point in time, and "model" moving the time-line forward monotonically. The information at your disposal consists of BARs of (OHLC). The OHLC is meant to characterize price action on the referenced bar. Of this data, two values (O__C) have a "time" reference, but the other two (_HL_) have no time reference within that BAR. You must insure if your criteria is impacted by the (HL) criteria, you guarantee the time line sequence, else you should avoid them! -- Otherwise you are subject to "cheating" by referencing events that may be in the "future" from your present time-line within the BAR!
    -- If you need to use the HL of the present BAR while processing the present BAR, just think thru your equations, to insure it is guaranteed to be "conservative"! -- It is typically easier to reference prior BARs, or Close of the current BAR to keep things simple, yet "probable".
     
    #13     Feb 24, 2017
    SimpleMeLike likes this.
  4. lovethetrade

    lovethetrade Guest

    Your initial post is a bit confusing. How many bars are you referencing to get a signal when you take your trade? How many bars do you "look-back'?

    Bar0 is the current bar that hasn't closed (I.e intrabar)
    Bar-1 is the last bar that closed
    Bar-2 is the 2nd last bar that closed
    And so on...

    At what stage during bar0 do you want to take your trade? When it opens or when a bar0 condition becomes true as well?

    Sounds like you're using 3-min intervals (time-frames)...
     
    Last edited by a moderator: Feb 24, 2017
    #14     Feb 24, 2017
  5. Your statement: "The strategy gives long signal on the current bar in the example at bar close."
    I think I read this as the signal occurs @ Close!
    If you are unable to use a signal that occurs prior to Close, then your trade would NOT fill on that BAR, but may fill on the next BAR.
    For some: Myself included, I code trading signals myself, I will use signals that occur 5-15min prior to close of a day, allowing me to respond to a signal without having to wait for the next day (This is referencing Daily BARs). Since I understand this, and am comfortable with variations in the last 5-15min, I can ASSUME, a Daily BAR signal @ Close, can yield a Fill @ close, for purposes of Back-testing to get a feel for the strategy. <-- Pardon, but I mixed in some "real trading" references to clarify why I allow a signal @ CLOSE to infer a trade @ CLOSE of the same BAR for special cases.
     
    Last edited: Feb 24, 2017
    #15     Feb 24, 2017
  6. Hello and thank everyone for responding trying to help me out.

    I know my questions seems simple to most people. but not for me.

    Let me explain a bit more what I am trying to understand regarding back testing with OHLC. I just want to fully grasp the how my back testing software works and understand so I don't make mistakes analyzing false strategy performance.

    Strategy to be programmed (for example):
    3 min bars
    breakout system
    if bar open and closes above line1 (line1 is some calculated price)
    entry = buy limit order < = line1
    stop loss = stop order 20 ticks
    profit target = 40 ticks
    vice versa for short.
    Strategies will be processed at the close of each bar

    Backtesting concern or questions:
    1. https://ninjatrader.com/support/helpGuides/nt7/?backtest_a_strategy.htm According to this document "During a backtest assumptions are made on the fill price of an order is based on the OHLC of a bar and the price of the order itself."

    Question 2. Since only the OHLC (4 data points) of a 3 min bar is used in back test, does this mean that if my limit, profit target, or stop price is somewhere between these 4 data, points, I will not get a fill order?

    For example during back testing:
    Close of a 3 min bar gives a buy signal.
    entry buy limit order = 53.52 or less

    The next 3 min bar forming is
    Open = 53.61
    High = 53.68
    Close = 53.56
    Low = 53.44

    Question
    Will my order fill at 53.44 because according to the link above only OHLC data is used when running the back testing software?

    Do you understand my confusion now?

    Thank you for reading.
     
    #16     Feb 24, 2017
  7. I do not use NinjaTrader, however, my interpretation will be as follows for your example:
    You will fill at 53.52! Since @ open (on the subsequent BAR), an order was present for Limit buy of 53.52 or better. Once price touches, (should occur prior to the LOW), you would be filled. This is reasonable to expect with a real trade with these conditions as well. If it indicates you get filled at 53.44, the back testing is flawed! <-- My 2 cents.
     
    #17     Feb 24, 2017
    SimpleMeLike likes this.

  8. Thank you stepandfetchit for responding.

    Yes!!, now you understand what I mean. I don't want flawed back testing. If 53.44 gets filled, then this is not right.

    So moving on:

    What means this what you say

    "You must insure if your criteria is impacted by the (HL) criteria, you guarantee the time line sequence, else you should avoid them! -- Otherwise you are subject to "cheating" by referencing events that may be in the "future" from your present time-line within the BAR!"

    What difference would it have made for my example if "enter trade at Low of next bar"?

    In this case enter at 53.44

    How would entering at next bar low of 53.44 be cheating?

    Thanks
     
    #18     Feb 24, 2017
  9. It is impossible to place an order to "enter trade at Low of next bar"! You will be unaware of what the LOW is until CLOSE. It is cheating, to "time travel to the future, to pick a price which you then know will occur in the future"! -- You may use data from the past, but never from the future. NEXT => Future!
    Is this clear?
     
    #19     Feb 24, 2017
  10. Thanks stepandfetchit for responding.

    Yess, that makes sense. Excuse me, you are right. i can not enter trade at low of next bar.

    Yes, that is clear, when I run the back testing software, I will not know data from the past at all. That would not make any sense for me to use data in the future for back testing.

    I am not sure how using future (or cheating) prices is even relevant to our conversation, unless I am missing something. If so, please let me know.

    Thanks,
     
    #20     Feb 24, 2017