Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter positions on Next Bar Close

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

    Enter positions on Next Bar Close

    Hi,

    Can NinjaTrader Strategies be configured to enter long/short positions on the close of the next bar?

    Thanks,

    James

    #2
    Hello,
    Through using custom logic you would be able do this.
    One process that I can think of is adding in a variable that you assign to CurrentBar and then check when the CurrentBar is equal to this value + 1.
    For example:
    private int myBar
    if(Conditions is true)
    CurrentBar = myBar;
    if(myBar == CurrentBar - 1)
    //The next bar has occurred.
    Last edited by NinjaTrader_CodyB; 03-06-2016, 04:37 PM.
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Cody that makes sense.

      Kind Regards,

      James

      Comment


        #4
        Originally posted by NinjaTrader_CodyB View Post
        Hello,
        Through using custom logic you would be able do this.
        One process that I can think of is adding in a variable that you assign to CurrentBar and then check when the CurrentBar is equal to this value + 1.
        For example:
        private int myBar
        if(Conditions is true)
        CurrentBar = myBar;
        if(myBar == CurrentBar - 1)
        //The next bar has occurred.
        myBar = CurrentBar;

        Comment


          #5
          Shouldn't myBar be initialized to CurrentBar first?

          Comment


            #6
            Originally posted by aaadetos View Post
            Shouldn't myBar be initialized to CurrentBar first?
            Never mind: private int myBar is within the vaiables region...

            Comment


              #7
              Thank you for bringing this to our attention, bltdavid. Here is an edited version of the above code.

              Code:
              [FONT=Courier New]private int myBar;
              private bool Conditions = false;
              if(Conditions)
                myBar = CurrentBar;
              if(myBar == CurrentBar - 1)
              {
                myBar = 0;
                //The next bar has occurred.
              }
              [/FONT]
              Jessica P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              81 views
              1 like
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              41 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              64 views
              2 likes
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              66 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              54 views
              0 likes
              Last Post CarlTrading  
              Working...
              X