Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars since Entry, Bars since Exit

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

    Bars since Entry, Bars since Exit

    I have watched numerous video and cannot find the simple answer to the following:
    I want the strategy to enter a position based on the Condition of a crossover but only after 10 bars have painted since the last exit.
    What do I put in the left box and where?
    What do I put in the right box and where?

    #2
    Hello TrendFollowingCapital,

    Thanks for your post.

    For the bar since exit execution, you have correctly selected the condition on the left. On the right side you need to select the "Misc" folder and from there select "Numeric value" and then enter the value of 10.

    Comment


      #3
      Hi Paul
      Thank you for your reply.
      I added in the variables exactly as you said now the strategy will not execute any positions at all.

      I heard on a video or a post somewhere you need to put in a -1 or something like that, but not able to remember where?

      There should really be a training video on this, it is very briefly mentioned in the Strategy builded 301 video or one of those but absolutely no clarification or working examples.
      I cannot find 1 vide on YouTube to explain how this feature works, perhaps you know of one?

      Comment


        #4
        Hello TrendFollowingCapital,

        Thanks for your reply.

        With reference to the help guide here: https://ninjatrader.com/support/help...texecution.htm that is correct, if there is no previous exit the method returns a -1. When used as an entry condition, this would prevent the first trade from occurring (and all other trades) unless you also accounted for the -1 value.

        In the strategy builder, you would have to create a "group" that is set to "If any" and then place both conditions in there of >10 and = -1. The "if any", in the group set only, creates the "or" condition. With the conditions set that way, when used as an entry condition the -1 value will be true allowing the first trade to occur and thereafter the -1 will no longer be returned and the method will return the number of bars since the latest exit.

        For your convenience, I have attached a screenshot that shows the "condition group" inside the condition of set 1 to help you recreate.

        Click image for larger version

Name:	TFC-1.PNG
Views:	2456
Size:	35.0 KB
ID:	1057804

        For further references on how to create a group condition, please see " How to create time filters" on this page: https://ninjatrader.com/support/help...on_builder.htm

        Comment


          #5
          Thank you Paul, this works perfectly, and the 1st time I have ever seen this explained properly.
          Kind regards, Jason

          Comment


            #6
            I am interested in limiting the number of trades executed by preventing new trades from executing until at 3 bars have printed. Something is wrong because no trades are taken under the strategy analyzer. Can you review my strategy?

            Click image for larger version

Name:	image.png
Views:	726
Size:	8.6 KB
ID:	1314561

            Comment


              #7
              Hello conniejforextrader,

              If the strategy is in the Strategy Analyzer, is there data appearing on the Chart Display of the Strategy Analyzer?

              Importantly, are there errors appearing on the Log tab of the Control Center?


              Try testing the Sample MA Crossover strategy included with NinjaTrader on the same chart or Strategy Analyzer using the same instrument, bar type, interval, and date range.

              Do you see results with the Sample MA Crossover strategy? (This would confirm for us data is available and the issue is with the logic in the custom script)


              If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the Log tab of the Control Center, and the Sample MA Crossover is returning results, then would likely indicate the logic conditions in the custom strategy did not evaluate as true or orders are being ignored or cancelled.

              In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.
              I'm also including a link to a forum post with further suggestions on debugging a script.


              Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


              Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

              Let me know if you need any assistance creating a print or enabling TraceOrders.

              Save the output from the output window to a text file and provide this with your reply.

              I'll be happy to assist with analyzing the output.​

              Comment


                #8
                Originally posted by conniejforextrader View Post
                I am interested in limiting the number of trades executed by preventing new trades from executing until at 3 bars have printed. Something is wrong because no trades are taken under the strategy analyzer. Can you review my strategy?

                Click image for larger version

Name:	image.png
Views:	726
Size:	8.6 KB
ID:	1314561
                Have you found a solution yet?

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                41 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                124 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                64 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
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X