Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by helpwanted, Today, 03:06 AM
    1 response
    14 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    6 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X