Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop

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

    Trailing stop

    I created a piece of code that calculates a new trailing stop within the On Bar Update method. The problem I am getting during back testing is that if, for example, I am short and calculating a trailing stop off the current low, sometimes the open of the next bar will be above the calculated stop and I get an error message: A BuyToCover stop order placed at '12/9/2009 9:35:00 AM' has been ignored since the stop price is less than or equal to the close price of the current bar.
    Is there an easy way of checking for this condition? I guess I could check the close of the current bar which should be somewhere near the open of the next bar where the stop order will be placed but it could gap and so it wouldn't really represent the open of the next bar. Hope this makes sense!

    -thanks

    #2
    laparker, correct you would need to check the stop price submitted at against the Close, for realtime use the current bid / ask (will be replaced with Close in backtesting).

    When working with Stop orders so close to the inside market, there's of course always this risk of submitting at a price leading to an invalid order.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X