Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How To Avoid Stop Loss triggering on entry bar?

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

    How To Avoid Stop Loss triggering on entry bar?

    Hi;
    I am just testing a breakout strategy with automated stop loss at 20 pips from entry. I am doing this on 1 minute chart, with data supplied by IB.

    I have noticed that on some occasions when there is a large bar (see attached image), the trade is entered near the top of the bar, but because the bar is large the SL is executed at the same time.

    Is there a way to have the SL and Profit taker to execute only on the next bar and not on the same bar than the entry.

    I am using this only for backtesting.

    Thanks
    Thomas
    Attached Files

    #2
    Originally posted by hometradingblog View Post
    Hi;
    I am just testing a breakout strategy with automated stop loss at 20 pips from entry. I am doing this on 1 minute chart, with data supplied by IB.

    I have noticed that on some occasions when there is a large bar (see attached image), the trade is entered near the top of the bar, but because the bar is large the SL is executed at the same time.

    Is there a way to have the SL and Profit taker to execute only on the next bar and not on the same bar than the entry.

    I am using this only for backtesting.

    Thanks
    Thomas
    You would have to custom code it. How you do that depends on how you are setting your stop loss, but basically, you would code a very large initial stop loss, then adjust it closer on the next bar.

    Of course, you must take account of the entry bar really representing a stop out, which for example it would be if the bar opened close to the top and closed under the desired stop loss, which would imply that the bar must have really traveled from the entry to the stop loss.

    Comment


      #3
      Hello,

      Once approach would be running the entry logic on every single tick, but only running the stop loss/profit target logic once per bar.

      Please see our Reference Sample on Separating logic to either calculate once on bar close or on every tick




      Please let me know if you have any questions.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Originally posted by koganam View Post
        You would have to custom code it. How you do that depends on how you are setting your stop loss, but basically, you would code a very large initial stop loss, then adjust it closer on the next bar.

        Of course, you must take account of the entry bar really representing a stop out, which for example it would be if the bar opened close to the top and closed under the desired stop loss, which would imply that the bar must have really traveled from the entry to the stop loss.
        Thanks, yes almost seems to work, I have one instance where I create two buy orders (and two stop orders). Interestingly enough it works for one but not for the other. This seems to be the exception so I am not too worried about.

        Still getting my head about the scripting and I might change the approach and use manual orders for profit taking and stop loss.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gemify, 11-11-2022, 11:52 AM
        6 responses
        803 views
        2 likes
        Last Post ultls
        by ultls
         
        Started by ScottWalsh, Today, 04:52 PM
        0 responses
        3 views
        0 likes
        Last Post ScottWalsh  
        Started by ScottWalsh, Today, 04:29 PM
        0 responses
        7 views
        0 likes
        Last Post ScottWalsh  
        Started by rtwave, 04-12-2024, 09:30 AM
        2 responses
        22 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        70 views
        0 likes
        Last Post tsantospinto  
        Working...
        X