Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

One Trade per Setup

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

    One Trade per Setup

    Is it possible to make a strategy in Builder that takes only one trade per setup? Sometimes at the close of the bar I have seen the same setup still intact and another trade is taken. Is there a way to limit one trade per setup and wait to take a trade till the next setup forms?

    #2
    Hello Trader17,

    You can use a bool for this.

    When the entry is submitted set the bool to true.

    When the position is back to flat (and Bars since exit execution is greater than -1) set the bool back to false.

    Require the bool to be false in the entry conditions.

    Below is a link to an example that uses bools in the Strategy Builder.

    Comment


      #3
      Thanks NinjaTrader_ChelseaB
      So will this wait for the setup to happen again? Not sure. Way I am using it is say after a Moving Average cross on the following bar closes if slow is above fast MA then go long. Now this can still be true after an exit. Like the slow can be above fast MA for many more bars. I want to wait now for the next cross up to trade.
      Thank you.

      Comment


        #4
        Hello Trader17,

        The suggestion I've made in post # 2 would be to reset for a new trade after the position has closed.

        However, you can design the custom logic to set the bool back to false based on your conditions.

        Comment


          #5
          So how can I wait in my case to wait for next cross for example to happen before checking for slow is over fast MA? Or bool cannot achieve that?
          Any examples or snippets of one trade per event? Wait for next event to look for next trade?
          Thanks.
          NinjaTrader_ChelseaB

          Comment


            #6
            Hello Trader17,

            You can use bools to wait for the next cross to occur. If you need two events to occur in sequence, use two bool.

            Below is a link to an example of using bools to require two events to occur in sequence.


            You will need to design the custom logic, such as what logic to use, but I can answer any specific questions if you have trouble setting up the custom logic in the Strategy Builder.

            Comment


              #7
              Thanks NinjaTrader_ChelseaB
              Where are the 2 events in the above example? I was trying to look for one trade only after a MA cross and then wait for a second cross to take a second trade and so on. I think years ago Paul had made something similar but he left Ninja and so it is not on forums anymore.
              Any specific event driven examples in NT8?
              Thanks.

              Comment


                #8
                Hello,

                This is Gaby following up for Chelsea who is out of office.

                The two events in that sample are both if (Close[0] > Open[0]). If you take a look at the code, it includes prints specifying that those are Events #1 and #2. These events are just examples, you could replace that logic with checking for a crossover if that is what you are looking for.

                Comment


                  #9
                  Thanks NinjaTrader_Gaby

                  I am still a bit unclear on this. Say the event is a MA cross up. After that we look for say 2 consecutive up bars to enter long. After that we wait for the following MA cross up to look for the next long trade. So MA cross will be one bool? Second bool will be the setup? And how do I prevent next trade until next cross up?
                  Thanks.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Gaby View Post
                    Hello,

                    This is Gaby following up for Chelsea who is out of office.

                    The two events in that sample are both if (Close[0] > Open[0]). If you take a look at the code, it includes prints specifying that those are Events #1 and #2. These events are just examples, you could replace that logic with checking for a crossover if that is what you are looking for.
                    I thought one was Close>Open and another was Close<Open. Both events were not Close>Open. Unless I am reading it wrong.
                    Thanks.
                    NinjaTrader_Gaby

                    Comment


                      #11
                      Hello Trader17,

                      With the SetTriggerForLaterConditionUsingBoolsBuilderExampl e, the trigger is set the first time the Close is greater than the open, the action is executed the second time the Close is greater than the open, and the trigger is reset for a new action when the Close is less than the open.

                      Comment


                        #12
                        Thanks NinjaTrader_ChelseaB

                        I do not want to wait for the trade to be executed the second time around as you mention above.
                        My situation is event and execution can trigger at same time. In that case we execute and now wait for next similar event to happen.
                        Say cross up is event and last 2 bars are green. Then event and execution triggered together like this at times. So take trade and wait till next cross up to form to trigger a trade. Because after a cross up for example there might be many more 2 consecutive green bars that we chose to ignore as trigger.

                        Comment


                          #13
                          Hello Trader17,

                          "Say cross up is event and last 2 bars are green."

                          This would be the first event. The trigger would be set. And you could submit an order if you wanted.

                          "wait till next cross up to form to trigger a trade"

                          This would be the second event. The action would be triggered.

                          You would also want a condition to reset the trigger if you want the action to occur again.

                          Comment


                            #14
                            Thank you NinjaTrader_ChelseaB

                            Can you post a snippet in here please? I am confused.

                            Comment


                              #15
                              Hello Trader17,

                              You are wanting me to post the code from the SetTriggerForLaterConditionUsingBoolsBuilderExampl e?

                              Set 1, this is where the bools are reset after both events have occurred
                              Code:
                              // Set 1
                              if ((TriggerSet == true)
                              && (ActionTriggered == true)
                              && (Close[0] < Open[0]))
                              {
                              TriggerSet = false;
                              ActionTriggered = false;
                              Draw.Line(this, @"SetTriggerForLaterConditionUsingBoolsBuilderExam ple Line_1 " + Convert.ToString(CurrentBars[0]), true, 0, (Low[0] + (-2 * TickSize)) , 0, (Low[0] + (-4 * TickSize)) , Brushes.CornflowerBlue, DashStyleHelper.Solid, 2);
                              Print(Convert.ToString(Times[0][0].TimeOfDay) + @" | TriggerSet and ActionTriggered reset to false for a new action");
                              }

                              Set 2, this is where your condition for the first event would go in place of Close[0] < Open[0].
                              Your first event would be "Say cross up is event and last 2 bars are green"​
                              Code:
                              // Set 2
                              if ((Close[0] > Open[0])
                              && (TriggerSet == true)
                              && (ActionTriggered == false))
                              {
                              ActionTriggered = true;
                              Draw.Dot(this, @"SetTriggerForLaterConditionExample Dot_2 " + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (3 * TickSize)) , Brushes.SpringGreen);
                              Print(Convert.ToString(Times[0][0].TimeOfDay) + @" | Second condition true, trigger the action. ActionTriggered set to true TriggerSet also true to prevent action until reset");
                              }
                              Set 3, this is where your condition for the second event would go in place of Close[0] > Open[0].
                              Your second event would be "wait till next cross up to form to trigger a trade"
                              Code:
                              // Set 3
                              if ((Close[0] > Open[0])
                              && (TriggerSet == false))
                              {
                              TriggerSet = true;
                              Draw.TriangleUp(this, @"SetTriggerForLaterConditionExample Triangle up_1 " + Convert.ToString(CurrentBars[0]), true, 0, (Low[0] + (-3 * TickSize)) , Brushes.Tomato);
                              Print(Convert.ToString(Times[0][0].TimeOfDay) + @" | First condition is true and the trigger is set for the second condition, TriggerSet set to true, ActionTriggered is false.");
                              }
                              ​​

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by abelsheila, 05-14-2025, 07:38 PM
                              2 responses
                              29 views
                              0 likes
                              Last Post hglover945  
                              Started by nailz420, 05-14-2025, 09:14 AM
                              1 response
                              57 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
                              0 responses
                              326 views
                              1 like
                              Last Post NinjaTrader_Brett  
                              Started by domjabs, 05-12-2025, 01:55 PM
                              2 responses
                              62 views
                              0 likes
                              Last Post domjabs
                              by domjabs
                               
                              Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
                              1 response
                              81 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Working...
                              X