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 Felix Reichert, 04-26-2024, 02:12 PM
    10 responses
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by PaulMohn, 04-24-2024, 03:49 AM
    4 responses
    35 views
    0 likes
    Last Post PaulMohn  
    Started by lightsun47, Today, 11:37 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by vitaly_p, Yesterday, 05:09 PM
    4 responses
    35 views
    0 likes
    Last Post vitaly_p  
    Started by bortz, 11-06-2023, 08:04 AM
    50 responses
    1,773 views
    0 likes
    Last Post carnitron  
    Working...
    X