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

Bars Since Entry/Exit

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

    #16
    If using bars since EXIT, if there have been no exits yet, what do you do to initiate the first trade?

    Comment


      #17
      Hello cupir2,

      BarsSinceExitExecution() will return a negative 1 if there have not been any exits.

      Below is a public link to the help guide on BarsSinceExitExecution().


      In the condition builder compare BarsSinceExitExecution() to a Misc > Numeric value and set the value to -1 to detect if no exit has been placed.

      Check for both BarsSinceExitExecution() and BarsSinceEntryExecution() to both have a value of -1 if you are wanting to detect when there have been no trades.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Using with strategy and OnBarClose and exit set to trigger as below

        (BarsSinceEntryExecution(0, "", 0) > 1)

        I want to be clear on when it will execute, I know that bar 0 where the 1 is shown would be the entry bar, when we close that bar then we are on bar 1, so greater than 1 will be when the next bar opens

        Question - will the exit order be sent instantly when that bar opens and if back testing the exit will calculate on the Open of that bar as well?

        Thanks

        Comment


          #19
          Hello DTSSTS,

          In backtesting everything is run OnBarClose, the order would be evaluated when the bar close is processed and OnBarUpdate is called. The historical fills would pass through the historical fill engine, you can read about that here: https://ninjatrader.com/support/help...lFillAlgorithm

          In a realtime situation and if the strategy is using OnEachTick calculation the order could be sent immediately. If you are using OnBarClose processing then the order will be submitted once the bar closes.

          JesseNinjaTrader Customer Service

          Comment


            #20
            (BarsSinceEntryExecution(0, "", 0) > 1)

            "once the bar close" is once bar 1 reference above closes, so in this code as soon as the 3 bar of the trade opens the the order is sent

            thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by geddyisodin, Today, 05:20 AM
            2 responses
            16 views
            0 likes
            Last Post geddyisodin  
            Started by hazylizard, Today, 08:38 AM
            0 responses
            6 views
            0 likes
            Last Post hazylizard  
            Started by Max238, Today, 01:28 AM
            5 responses
            42 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by giulyko00, Yesterday, 12:03 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by habeebft, Today, 07:27 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Working...
            X