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 sjsj2732, Yesterday, 04:31 AM
    0 responses
    31 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    286 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    283 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    133 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    91 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X