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

Controlling when trailing stops are entered

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

    Controlling when trailing stops are entered

    I'm having some issues setting my trailing stops and appreciate any overview advice on how to do it in NT.

    I want to enter my trailing stop only after a certain number of bars since entry.

    I thus wrote:
    if (BarsSinceEntry() > 5)
    {
    SetStopLoss(blah, blah);
    }

    However, I see that NT is in fact firing my stoploss the same bar I have my entry...I read that this is the default in the helpfile.

    Anyway, I do not want that - how do I take control of when my stop loss is entered? I don't want NT's default behaviour and yet everything I code, it ignores and puts it in right away regardless.

    In addition, I note that in backtesting, having the stop loss fire on the same bar is also resulting in ridiculous stop outs...its fairly clear that NT is making some gross, worst case assumptions about what happened in that bar and stopping you out based simply on whether your stop *could have been hit* and not whether it really was hit (i.e. the width of a 10 min bar covers the stop, but looking at the minute chart you see that from entry to close of the bar, the stop loss was never touched)...so if there is any info on how to control that as well, I would appreciate it.

    Thanks

    #2
    Never mind, figured it out.

    SetStopLoss autofires regardless of conditions surrounding it...it fires when you original entry takes place.

    ExitLongStop() gives you the ability to wrapper your exit stops in controllable conditions....


    That said, any info on how to control NT's behaviour of what happens inside a bar during backtesting would be appreciated. Its clear its taking the worst case scenario (which is fine) but I want to see if there any 'look inside the bar' controllable options.

    Comment


      #3
      You would need to add a reference to an intrabar granularity for this -

      You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


      NinjaTrader would always take the most conservative approach to fills, thus if both stop and target could have triggered intrabar, we would assume it was the stop...
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Thanks Bertrand...thats what I needed, and that reference section is a gold mine - I didn't realize it was there but its a huge help.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cyberpete76, 03-27-2023, 12:29 AM
        6 responses
        261 views
        1 like
        Last Post slightly  
        Started by slightly, Today, 12:49 AM
        0 responses
        2 views
        0 likes
        Last Post slightly  
        Started by sdauteuil, 09-23-2021, 10:16 AM
        4 responses
        1,208 views
        0 likes
        Last Post jacobpescaia44  
        Started by agclub, 04-21-2024, 08:57 PM
        5 responses
        34 views
        0 likes
        Last Post agclub
        by agclub
         
        Started by ESHunter, Yesterday, 08:06 PM
        2 responses
        18 views
        0 likes
        Last Post ESHunter  
        Working...
        X