Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Restrict strategy to only one order per trend

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

    #16
    Hello Chelsea,

    That
    Are you wanting to submit the order on each new bar to keep it alive?
    is exactly what i want.

    Thanks & Regards
    Maaz Khan

    Comment


      #17
      Hello Maaz,

      Add an additional bool.

      When the entry conditions are true set the bool to true (but don't submit the order).

      In a separate condition check the position is long and set the bool to false.

      In another separate condition check the bool is true and submit the order.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hello Chelsea,

        Apologies for the confusion but can you please add a little detail to the description?

        Thanks & Regards
        Maaz Khan

        Comment


          #19
          Hello Chelsea,

          I tried a couple of ways to interpret your directions for the additional bool but i am unable to work it out. Can you please add a little clarity to your previous response.
          Also i have looked into the thread you mention but that is about trailing stops and breakeven, i tried some of those relevant techniques too but that didn't work either.

          Thanks & Regards.

          Comment


            #20
            Hello maaxk,

            I've made a video demonstration.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Hello Chelsea,
              I have replicated your strategy and this is the output. I have attached the output file and a screenshot of the chart drawing plotted as well.

              What i want is to enter single long position per bullish trend and then when the bearish trend is detected reset the flag to false so it can take another long position.

              Click image for larger version

Name:	image.png
Views:	49
Size:	636.6 KB
ID:	1328723

              Thanks & Regards
              Maaz Khan

              Comment


                #22
                Hello maaxk,

                "What i want is to enter single long position per bullish trend and then when the bearish trend is detected reset the flag to false so it can take another long position."

                Is this what you coded in the script?

                Are you printing the values compared in the entry condition?

                May I confirm you watched the entire video, including where I modified the entry and reset conditions with what you suggested and printed the values?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Hello Chelsea,

                  Yes, I did watch the entire video and i watched it again and i was missing a part where you removed the grouped conditions and entered my conditions, i made that correction and reloaded it.
                  Here is the screenshot of the chart and i have also attached the output, please navigate to the latest eateries and there you will find the eateries plotted on chart.

                  Click image for larger version  Name:	image.png Views:	0 Size:	718.3 KB ID:	1328732

                  Now the problem i was trying to address is that reset the order allowing flag to true once bearish trend is detected, that way it will only allow one long trade per bullish trend, so the flag will remain true until bearish is detected again.

                  Note:
                  I am using a different chart, see if you can open this specific chart and run the strategy on it.
                  Let me know if you need any further supporting information on the issue.

                  Thanks & Regards
                  Maaz Khan
                  Last edited by maaxk; 12-20-2024, 01:10 PM.

                  Comment


                    #24
                    Hello maaxk,

                    By eateries are you meaning entries?

                    "Now the problem i was trying to address is that reset the order allowing flag to true once bearish trend is detected, that way it will only allow one long trade per bullish trend, so the flag will remain true until bearish is detected again."

                    Model the conditions and actions as shown in the video I have provided you.

                    This resets for a new entry when the low of the current bar is less than the low of the previous bar and the low of the previous bar is less than the low of the preceding bar.

                    This prints 'Condition Set 3 true, resetting AllowEntry to false for new entry' when the condition to reset has evaluated as true.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Hello Chelsea,
                      I hope you had a good weekend.

                      I molded the conditions to achieve a single order per bullish trend and I achieved it but there's one problem and that is that the limit price is not updating on each bar close. Like it submits the limit order but it stays there mean it doesn't not go up along with the price. I tried a couple of different ways but Its not happening.

                      Please have a look at the conditions and actions in the sets, i have molded the conditions as per my understanding of achieving the output.

                      Print(Convert.ToString(Times[0][0]) + @" | Submit Entry Order " + Convert.ToString(SubmitEntryOrder) + @" , Allow Entry " + Convert.ToString(AllowEntry) + @" , Market Position " + Convert.ToString(Position.MarketPosition) + @" ,Close[0]: " + Convert.ToString(Close[0]) + @" , Close[1]: " + Convert.ToString(Close[1]) + @" , Close[2]: " + Convert.ToString(Close[2]) + @" , Low[0]: " + Convert.ToString(Low[0]) + @" , Low[1]: " + Convert.ToString(Low[1]) + @" , Low[2]: " + Convert.ToString(Low[2]));
                      // Set 2
                      if ((SubmitEntryOrder == true)
                      && (Position.MarketPosition == MarketPosition.Long))
                      {
                      SubmitEntryOrder = false;
                      Print(Convert.ToString(Times[0][0]) + @" | Contition set 2, entry has filled resetting submit entry order to false");
                      Draw.Dot(this, @"Dot Condition 2 " + Convert.ToString(CurrentBars[0]), true, 0, (Low[0] + (-3)) , Brushes.Goldenrod);
                      }

                      // Set 3 resets the allow entry o false
                      if ((Low[0] < Low[1])
                      && (Low[1] < Low[2]))
                      {
                      AllowEntry = false;
                      Print(Convert.ToString(Times[0][0]) + @" | Contition set 3, resetting Allow entry order to false");
                      Draw.Dot(this, @"Dot Condition 2 " + Convert.ToString(CurrentBars[0]), true, 0, (Low[0] + (-5)) , Brushes.Sienna);
                      }

                      // Set 4 sets the submit order condition to true.
                      if ((AllowEntry == false)
                      && (SubmitEntryOrder == false)
                      && (Position.MarketPosition == MarketPosition.Flat)
                      && (Close[0] > Close[1])
                      && (Close[1] > Close[2]))
                      {
                      LimitPrice = (GetCurrentAsk(0) + (-10 * TickSize)) ;
                      SubmitEntryOrder = true;
                      Print(Convert.ToString(Times[0][0]) + @" | Condition 4 , entry conditions");
                      Draw.TriangleUp(this, @"Traingle up condition set 4 " + Convert.ToString(CurrentBars[0]), false, 0, (Low[0] - 1) , Brushes.DarkGreen);
                      }

                      // Set 5 checks is submit order is true then enter limit order.
                      if (SubmitEntryOrder == true)
                      {
                      Print(Convert.ToString(Times[0][0]) + @" | Condition set 5 submiting order");
                      EnterLongLimit(Convert.ToInt32(DefaultQuantity), LimitPrice, "");
                      Draw.Line(this, @"Line Condition set 5 " + Convert.ToString(CurrentBars[0]), true, 0, LimitPrice, 1, LimitPrice, Brushes.Lime, DashStyleHelper.Solid, 2);
                      }

                      // Set 6 checks if the position is long then set allow entry to true to restrict further entries.
                      if (Position.MarketPosition == MarketPosition.Long)
                      {
                      SubmitEntryOrder = false;
                      Print(Convert.ToString(Times[0][0]) + @" Condition set 6, exit conditions");
                      ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
                      Draw.TriangleDown(this, @"Traingle down condition set 6 " + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + 1) , Brushes.Red);
                      AllowEntry = true;
                      }​

                      like if you see set 6it doesn't make any sens to not update the limit price as the price goes higher. I have also attached the output and the screenshot of the chart plotting.

                      Click image for larger version

Name:	image.png
Views:	48
Size:	692.6 KB
ID:	1328959

                      I would appreciate if you can help me out.

                      Thanks & Regards
                      Maaz Khan

                      Comment


                        #26
                        Hello maaxk,

                        The video does not include an additional condition set for modifying the limit price.

                        Add a new condition set before set 5 looking for SubmitEntryOrder to be true and the conditions you want to modify the limit price.
                        In the actions set the new limit price.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        558 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        324 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
                        545 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        547 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X