Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

One Trade Per Direction Problem

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

    #16
    m3power222,

    You can create a user variable of type bool in the User Defined Inputs page. Then in the Condition Builder you can set it to true or false as you deem necessary. Then as it comes to a new trading day you can reset that bool variable to whatever state you need it to be.

    Unfortunately we do not have sample code.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by NinjaTrader_Josh View Post
      m3power222,

      You can create a user variable of type bool in the User Defined Inputs page. Then in the Condition Builder you can set it to true or false as you deem necessary. Then as it comes to a new trading day you can reset that bool variable to whatever state you need it to be.

      Unfortunately we do not have sample code.

      This seems like a common answer to a lot of questions using a bool flag. Why isn't there samples?

      Comment


        #18
        This is a very basic programming concept and you can find code snippets throughout the forums demonstrating it. There is no "sample" because the concept is generally specifically tailored to a particular cases.

        You can also find many resources on this on google too.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Sooooo close!!!!! I added:

          #region Variables
          private bool boolFlag = true;

          if (condition long
          && boolFlag == true)
          {
          enter long
          boolFlag = false;
          }

          if (condition short
          && boolFlag == true)
          {
          enter short
          boolFlag = false;
          }


          So now it will take only 1 trade period. But I need it to take 1 trade long if condition is met and 1 trade short if condition is met per day.

          From my reading a bool flag can only be true or false? If I could do a true1, true2, etc I think my problem would be solved.

          Any other ideas? At least now it will only just 1.

          Comment


            #20
            m3power222,

            If you want a long and a short you should use two bool flag variables, one for each.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              Originally posted by NinjaTrader_Josh View Post
              m3power222,

              If you want a long and a short you should use two bool flag variables, one for each.
              That did the trick:

              private bool entrylong = true;
              private bool entryshort = true;


              Thanks Josh.


              Is there a way to reset it to true for the next day without readding the strat? Reason being is if I just keep it connected 24x7 as I have logic to only enter trades mon-fri from x time to y time.

              Comment


                #22
                Code:
                if (Bars.FirstBarOfSession && FirstTickOfBar)
                {
                     entrylong = true;
                     entryshort = true;
                }
                Josh P.NinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by NinjaTrader_Josh View Post
                  Code:
                  if (Bars.FirstBarOfSession && FirstTickOfBar)
                  {
                       entrylong = true;
                       entryshort = true;
                  }

                  Thanks again, can't test it as market replays are one day at a time.

                  Unless there is a way to string them together?

                  Comment


                    #24
                    One at a time for Market Replay. NT7 will allow you to string them together.
                    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
                    633 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    364 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    105 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    567 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    568 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X