Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Builder limiting trades.
Collapse
X
-
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.
-
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
-
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
-
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
-
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
-
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?Originally posted by NinjaTrader_Emily View PostHello 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.
Comment
-
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:Then, if the condition that checks for a new trade is met, you can increment the counter as shown in these screenshots:
This creates it as a Series<double> object within the script itself:
Please let us know if we may be of further assistance.
Comment
-
Thanks NinjaTrader_Emily Is there one built this way sample in builder already?Originally posted by NinjaTrader_Emily View PostHello 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.
Thank you.
Comment
-
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.
Thank you for your time and patience.Last edited by NinjaTrader_Emily; 08-30-2023, 02:54 PM.
Comment
- Post number 2
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
146 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
79 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
50 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
54 views
0 likes
|
Last Post
|
Comment