Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Builder limiting trades.

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

    Strategy Builder limiting trades.

    Is there a way in Strategy Builder to limit number of trades per bar while calculating on each tick? Is there a way for it to do that? Like keep a count per bar of closed trades?
    Thanks.

    #2
    Hello Trader17,

    Thank you for your post.

    You could consider using a custom series to keep count of how many trades per bar and add a check in your condition that the series is less than or equal to the desired limit. There is a Strategy Builder example of an event counter attached to the following post:
    Is there a way to increment an int in the strategy builder? When I go to set an int equal to itself there's no way to add 1 to it as well. Just wondering if this is possible in the wizard.


    Please let us know if we may be of further assistance.

    Comment


      #3
      Thanks NinjaTrader_Emily Or can I make a simple counter for the trades taken and check to see that number is less than or equal to desired trades when CurrentBar == 0?
      Thanks.

      Comment


        #4
        Hello Trader17,

        Thank you for your reply.

        By CurrentBar == 0, do you mean the current bar that is 0 bars ago? CurrentBar is an absolute bar index, so bar 0 is the first bar on the leftmost side of the chart. I just want to clarify and make sure we are referring to the same thing and help you to make sure you are referencing the correct bar.

        If you only want to make a counter that starts at 0 for each bar and increments during that same bar based on how many trades, it would be very similar to that example I linked to but you could remove the condition set that updates the 0 bars ago value for myCounter to equal myCounter from 1 bar ago:
        World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


        Instead, you could have a condition that checks if it is the first tick of bar, and if so you reset the counter for 0 bars ago to 0:Then, if the condition that checks for a new trade is met, you can increment the counter as shown in these screenshots:Your conditions for a new entry could check that the counter is less than or equal to the desired limit. For example:I hope this helps to clarify; please let me know if I may be of further assistance.

        Comment


          #5
          Thanks NinjaTrader_Emily what I was wanting to know is how to differentiate between current bar building and the bar just before it. I was thinking of using that bar number to limit trades. Like is there a way we can use the current bar forming and compare it to the bar that just closed before it. So if bar is the one forming and trade counter < X then take trade. So do not take more than X trades on the bar that is forming when we use calculate on each tick.

          I might use the trade counter and reset it on first tick of bar most likely as it should accomplish what I am trying to do.
          Last edited by Trader17; 08-28-2023, 02:36 PM.

          Comment


            #6
            Hello Trader17,

            Thank you for your reply.

            The current bar forming is considered to be 0 bars ago, and the bar before it is 1 bar ago. You can certainly make comparisons between values from 0 bars ago and 1 bar ago. This is similar to the example "How to make price data comparisons" on the following page:


            The comparison checks if the current close price is greater than the close price from 1 bar ago, using the bars ago field in the builder.

            Please let me know if I may be of further assistance.

            Comment


              #7
              Originally posted by NinjaTrader_Emily View Post
              Hello Trader17,

              Thank you for your reply.

              The current bar forming is considered to be 0 bars ago, and the bar before it is 1 bar ago. You can certainly make comparisons between values from 0 bars ago and 1 bar ago. This is similar to the example "How to make price data comparisons" on the following page:


              The comparison checks if the current close price is greater than the close price from 1 bar ago, using the bars ago field in the builder.

              Please let me know if I may be of further assistance.
              Thanks NinjaTrader_Emily I am not comparing anything on 2 bars but trying to add up trades on the last forming bar itself. That is why I was asking if we could use some sort of index on the current bar forming to calculate trades it took on it. Makes sense?
              Thanks.

              Comment


                #8
                Hello Trader17,

                Thank you for your reply.

                Yes, there is a barsAgo index for the current bar forming and it is 0. To add trades on the last forming bar as they are happening, that is what I demonstrated previously:
                Then, if the condition that checks for a new trade is met, you can increment the counter as shown in these screenshots:
                What I mean by incrementing the counter is increasing it by 1, on the current bar/0 barsAgo, when a new trade occurs. myCounter is a series and the goal of the example is to add to the current bar's value as trades are taken on that bar. That value will be held in the series myCounter. The custom series is added via the Additional Data screen in the Strategy Builder:


                This creates it as a Series<double> object within the script itself:


                Please let us know if we may be of further assistance.

                Comment


                  #9
                  Originally posted by NinjaTrader_Emily View Post
                  Hello Trader17,

                  Thank you for your reply.

                  Yes, there is a barsAgo index for the current bar forming and it is 0. To add trades on the last forming bar as they are happening, that is what I demonstrated previously:


                  What I mean by incrementing the counter is increasing it by 1, on the current bar/0 barsAgo, when a new trade occurs. myCounter is a series and the goal of the example is to add to the current bar's value as trades are taken on that bar. That value will be held in the series myCounter. The custom series is added via the Additional Data screen in the Strategy Builder:


                  This creates it as a Series<double> object within the script itself:


                  Please let us know if we may be of further assistance.
                  Thanks NinjaTrader_Emily Is there one built this way sample in builder already?
                  Thank you.

                  Comment


                    #10
                    Hello Trader17,

                    Thank you for your reply.

                    Yes, I included a link to the EventCounterExample in my first reply to this thread:
                    • Post number 2
                      • Here is the link again: https://forum.ninjatrader.com/forum/...86#post1099186
                      • To see the example, download the attachment at that post and then go to Control Center > Tools > Import > NinjaScript AddOn. Select the downloaded file. Once the import is complete, the example will be an option in the Strategy Builder dropdown menu that you can review by clicking through the screens and seeing how it is set up.
                    My responses have been in relation to that example and attempting to explain how it works, as well as what modifications you could consider making depending on your needs. Please review the post at that link, which has an explanation of how the example uses a custom series as a counter, and let me know if you have any remaining questions.

                    Thank you for your time and patience.
                    Last edited by NinjaTrader_Emily; 08-30-2023, 02:54 PM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, 03-13-2026, 05:17 AM
                    0 responses
                    84 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    150 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    79 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    52 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    59 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X