Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

time between trades

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

    time between trades

    hi i want a guide for how can I set a condition to set a candle number between trades as an example to be at least 10 candles between the exit and re-entry of other trade

    #2
    You could create a variable like int CandlesAfterTrade and set that to 0 once a trade has exited. Add to it every candle. In order to take a trade again, you need your normal conditions, but also CandlesAfterTrade >= 10. Is that what you were looking for?

    Comment


      #3
      I have been trying to do the same thing in my strategy as to not take trades too soon after a trade finishes, so I don't chase trades that may be moving against my bias. If anyone can provide working code of how to accomplish a "barsToWait" logic, that would be great.

      Comment


        #4
        What does your code look like?

        Comment


          #5
          Hello Adamel,

          Welcome to the NinjaTrader forums!

          The BarsSinceExitExecution() may be what you are looking for.
          Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


          Your condition can require this value to be either equal to -1 (no exit has been made) or greater than 10.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by rockmanx00 View Post
            You could create a variable like int CandlesAfterTrade and set that to 0 once a trade has exited. Add to it every candle. In order to take a trade again, you need your normal conditions, but also CandlesAfterTrade >= 10. Is that what you were looking for?
            yes, I think you understand me but I still do not get the condition you said how the condition would be like.

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello Adamel,

              Welcome to the NinjaTrader forums!

              The BarsSinceExitExecution() may be what you are looking for.
              Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


              Your condition can require this value to be either equal to -1 (no exit has been made) or greater than 10.
              ​I made it like this but I get 0 trade why? what I need to change ?

              Comment


                #8
                Hello Adamel,

                In the future, be sure to mention if you are using the strategy builder and not coding the script by hand.

                Attached is an example made with the strategy builder.
                BarsSinceExitTest_NT8.zip

                The check for bars since exit being equal to -1 or greater than or equal to 10 is in a condition group using 'If Any' to join the condition with ORs.
                The other conditions for entry would be added to the condition set, but not within the bars since exit condition group.
                This will draw a dot and submit an entry 10 bars after the last exit.

                Below I am including a link to a support article with helpful resources on getting started with NinjaScript and C#, and includes links to training videos.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello Adamel,

                  In the future, be sure to mention if you are using the strategy builder and not coding the script by hand.

                  Attached is an example made with the strategy builder.
                  [ATTACH]n1336101[/ATTACH]

                  The check for bars since exit being equal to -1 or greater than or equal to 10 is in a condition group using 'If Any' to join the condition with ORs.
                  The other conditions for entry would be added to the condition set, but not within the bars since exit condition group.
                  This will draw a dot and submit an entry 10 bars after the last exit.

                  Below I am including a link to a support article with helpful resources on getting started with NinjaScript and C#, and includes links to training videos.
                  https://support.ninjatrader.com/s/ar...th-NinjaScript
                  yes I'm using ninja trading strategy builder I do the as a group but still face problems I get no change so he condition is not working I tried 10 bars and 30 bars even 300 bars and no change soo what I'm doing wrong?
                  Attached Files
                  Last edited by Adamel; 02-27-2025, 02:31 PM.

                  Comment


                    #10
                    Hello Adamel,

                    To confirm you are testing the example script I provided you and no trades are appearing?

                    Is the BarsSinceExitTest strategy applied to a chart and enabled?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello Adamel,

                      To confirm you are testing the example script I provided you and no trades are appearing?

                      Is the BarsSinceExitTest strategy applied to a chart and enabled?
                      I don't use the script because I'm using the strategy builder and not coding the script by hand when I set the condition nothing change so he condition not working it's give's me the same results without it
                      when I check the code it look like this // Condition group 1
                      && ((BarsSinceExitExecution(0, @"BUY", 0) > 300)
                      || (BarsSinceExitExecution(0, @"BUY", 0) == -1)))​
                      Last edited by Adamel; 02-27-2025, 03:01 PM.

                      Comment


                        #12
                        Hello Adamel,

                        The script I provided you was created in the Strategy Builder and opens in the Strategy Builder.

                        Can you clarify why you are not using the strategy builder example I provided you?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello Adamel,

                          The script I provided you was created in the Strategy Builder and opens in the Strategy Builder.

                          Can you clarify why you are not using the strategy builder example I provided you?
                          now its works the problem was with the single name

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          23 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          120 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          63 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          41 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          45 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X