Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple entries

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

    Multiple entries

    Hello,

    Does anyone know what the Ninja code would be to do the following...

    If a trade was exited, then don't allow an entry on the next bar.

    Thank you.

    Razor

    #2
    Razor,

    Perhaps this might help:

    Code:
    if (BarsSinceExit() < 1) return;
    This would basically say if a trade was exited 1 bar ago, don't do anything until the next bar.

    More on BarsSinceExit() is available in the help index.

    Good luck,
    Mike

    Comment


      #3
      Thanks Mike, I'll give it a try.

      Comment


        #4
        The "if (BarsSinceExit() < 1) return;" doesn't seem to be working. I still get entries on consecutive bars.

        Any ideas?

        Thank you.

        Comment


          #5
          Razor_Trader,

          What is your exact code structure looking like right now? Thanks.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Josh,

            An outline of my code is....

            protected override void OnBarUpdate()
            {
            if (BarsSinceExit() < 1) return;

            If (Conditon1 && Condition2)
            {
            EnterLongLimit();
            }

            If (Condition3 && Condition4)
            {
            EnterShortLimit();
            }
            }

            Comment


              #7
              I moved the "if (BarsSinceExit() < 1) return;" statement into a different place in the code. I can get it to work on long entries only or short entries only but not both long and short entries.

              For example it works for long entries only when I put the "if (BarsSinceExit() < 1) return;" statement as follows...

              protected override void OnBarUpdate()
              {

              If (Conditon1 && Condition2)
              {
              if (BarsSinceExit() < 1) return;
              EnterLongLimit();
              }

              If (Condition3 && Condition4)
              {
              EnterShortLimit();
              }
              }

              Comment


                #8
                If I put the "if (BarsSinceExit() < 1) return;" in the code twice, then I get no trades at all. As in the following...

                protected override void OnBarUpdate()
                {

                If (Conditon1 && Condition2)
                {
                if (BarsSinceExit() < 1) return;
                EnterLongLimit();
                }

                If (Condition3 && Condition4)
                {
                if (BarsSinceExit() < 1) return;
                EnterShortLimit();
                }
                }

                Comment


                  #9
                  Razor_Trader,

                  I suspect you are running into Internal Order Handling Rules. Please check your Control Center for errors.

                  Please review the bottom of this article for the rules: http://www.ninjatrader-support.com/H...verview36.html
                  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
                  571 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  330 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  548 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  549 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X