Announcement

Collapse
No announcement yet.

Stops are taking out trade on entry bar

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

  • Stops are taking out trade on entry bar

    I've entered the Example #3 Three Bar Breakout Trading System and when tested, each trade is being immediately taken out by the stops on the same entry bar. The code is:
    Strategy.doLong("",Strategy.CLOSE,Strategy.THISBAR ,Strategy.DEFAULT,0)
    Strategy.setStop(low())

    The idea is to go long at the Closing Price of the current bar and to set the stop to the low of the current bar -- to execute only if the stop is hit in future bars.

    For this and other strategies, the choice to doLong depends on other indicators (other than price) which vary within a bar. The idea is to test those values AT THE CLOSE ONLY. Is this the issue, and if so, how can that be specified??

    What's going on?? Thanks.
    Last edited by FiveString; 03-27-2006, 03:09 PM.

  • #2
    Re: Stops are taking out trade on entry bar

    Hello FiveString,

    Originally posted by FiveString
    I've entered the Example #3 Three Bar Breakout Trading System and when tested, each trade is being immediately taken out by the stops on the same entry bar. The code is:
    Strategy.doLong("",Strategy.CLOSE,Strategy.THISBAR ,Strategy.DEFAULT,0)
    Strategy.setStop(low())

    The idea is to go long at the Closing Price of the current bar and to set the stop to the low of the current bar -- to execute only if the stop is hit in future bars.
    Setting the stop at the low (or high) of the entry bar was a logical oversight in the original formula for this example. When using .setStop(), the stop price level should not be within the range of the entry bar or it will immediately stop out. For this example subtract 0.25 from the low in the .setStop(low()-.25) and add 0.25 to the high for the short stop. I've updated the example for this strategy in the KnowledgeBase. Thank you for bringing this error to our attention. For comparison, you may download the completed code for this example from our EFS Library, FWguide3BarBrkOut.efs.

    For this and other strategies, the choice to doLong depends on other indicators (other than price) which vary within a bar. The idea is to test those values AT THE CLOSE ONLY. Is this the issue, and if so, how can that be specified??

    What's going on?? Thanks.
    In back testing, only completed bars are analyzed. By default, back testing formulas only have access to the values of the various indicators and OHLC prices at the close of the bar.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thank you. With this I am able to make my model work, but there are many times I want to set a stop less than the high or low of the bar I am entering at the close. I hope the programming for backtesting can be fixed to only have the stop effective for future bars. Any hope?

      Comment


      • #4
        Hello FiveString,

        Originally posted by FiveString
        Thank you. With this I am able to make my model work, but there are many times I want to set a stop less than the high or low of the bar I am entering at the close. I hope the programming for backtesting can be fixed to only have the stop effective for future bars. Any hope?
        The problem that you are dealing with is a logic problem that needs to be handled by your code. It is not something that needs to be fixed or changed in the functionality of the Strategy object. What you first need to consider is that the logic you are currently using will not create realistic results by entering a position at the close of the bar based on a condition triggered by that close. At the very earliest, you wouldn't be filled until at least the next trade, which would be the opening trade of the following bar. Also, in real time trading EFS does not know which trade is going to be the close of the bar until the first trade of the following bar occurs. In order to simulate the most realistic results in a back testing formula you should change your back testing logic to enter the trade with the MARKET/NEXTBAR constants. That way, your .setStop() call will not be evaluated until the next bar where the position is taken, which will accomplish the logic you're after.

        Some users evaluate the prior bar's data and use the MARKET/THISBAR combination to enter the position on the current bar at the open. In their case, subsequently calling .setStop() on the same bar works fine because the logical order of trading makes it realistic to enter a position at the open of a bar and exit at a stop price that is within the bar's range on the same bar. If we were to change the behavior of the setStop() method as you have requested, it might fix the logic problem for your current formula, but would break others. Hope this helps.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          I think I understand. Will change my code and try it. Thanks.

          Comment

          Working...
          X