Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit on bar close

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

    Exit on bar close

    Hi again,

    How can I add "exit on bar close" or exit on X bar close? I know only how to make stop loss and profit targets, but i want to try backtest these "on bar close "exits.

    How can I do it in ninjascript wizard?

    Thank you for your help

    Kamil

    #2
    Hello,

    Thanks for your forum post.

    This is set when you run the strategy. When you start it there will be setting for Calculate on Bar Close = True or False, you want this set to True.

    Also, during a back test Calculate OnBar Close is always used.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      First of all, thank u for your respond :-)

      At second: I dont understand :-( Everywhere I have CalculateOnBarClose = True.

      But when Iam building this strategy in wizard, I enter in row named "when conditions are true" some conditions and in "do the following" i enter: Enter long position. It will enter position on Open, but how can I add exit on close of this bar. I can only add SL and PT on next page.

      thank u

      Comment


        #4
        Please tell me, if u dont understand what i mean.I ll try it to write better.

        Comment


          #5
          Hello,

          Are you running this live or in a backtest?

          I look forward to assisting you further.
          BrettNinjaTrader Product Management

          Comment


            #6
            In backtest.

            Comment


              #7
              Hello,

              Ok in this case with backtester how the backtester is designed is that all order actions must take place on the open of the next bar after your conditions have become true.

              Therefor on each OnBarUpdate() will occur for each new bar on the open of the next bar.

              There is no way to customize something ot occur at the close of the bar at this time with the backtester.
              BrettNinjaTrader Product Management

              Comment


                #8
                Ok, so can u help me how can I exit on next bar open. if its Open>open of bar where I enter?

                Comment


                  #9
                  You can get the bar number that you entered at with BarsSinceEntry().

                  Code:
                  if (Open[0] > Open[BarsSinceEntry()])
                       ExitLong();
                  This will close you out at the next bar's open.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  368 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  571 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X