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

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 geddyisodin, 04-25-2024, 05:20 AM
              8 responses
              60 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              4 responses
              3,285 views
              1 like
              Last Post jgualdronc  
              Started by Option Whisperer, Today, 09:55 AM
              0 responses
              5 views
              0 likes
              Last Post Option Whisperer  
              Started by halgo_boulder, 04-20-2024, 08:44 AM
              2 responses
              22 views
              0 likes
              Last Post halgo_boulder  
              Started by mishhh, 05-25-2010, 08:54 AM
              19 responses
              6,189 views
              0 likes
              Last Post rene69851  
              Working...
              X