is there a way of limiting the number of trades executed per bar? Im using an intrabar strategy and I want to only execute a maximum of two trades per bar. Thanks for your help in advance
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Limiting Trades per bar
Collapse
X
-
Limiting Trades per bar
Hello guys,
is there a way of limiting the number of trades executed per bar? Im using an intrabar strategy and I want to only execute a maximum of two trades per bar. Thanks for your help in advanceTags: None
-
Hi there, in order to limit the number of trades per bar, I would recommend monitoring the number of trades placed while inside the secondary (more fine) instrument's BarsInProgress index and resetting the value for every main bar update. Then you can tell the strategy to not place any more trades if it has already placed two.AustinNinjaTrader Customer Service
-
-
Same Problem
I would also like to just make 2 trades per bar in a strategy that is set to On Bar Update False. I tried the Performance.AllTrades.TradesPerformance.MaxConsecW inner < 2 but I had to manually turn it off and on to reset for the next bar. Could I possibly get a piece of sample code for the problem solve suggested here. I looked at the Sample Data Series code but I didn't see how one would reset after the main bar update also how you would keep track of the number of trades executed in the lower time frame.
Thanks for any help.
Comment
-
cre8it8, you will need some sort of counter to keep track of how many orders have been placed per bar, and then reset at the first tick of every new bar with FirstTickOfBar.
The could would probably look something like this:
You would need to monitor all of this in the small timeframe's BarsInProgress context:Code:OnBarUpdate() { if (FirstTickOfBar) thisBarTrades = 0; if (long entry conditions are true) { EnterLong(); thisBarTrades = thisBarTrades + 1; } if (short entry conditions are true) { EnterShort(); thisBarTrades = thisBarTrades + 1; } }
Please let me know if you have any other questions.Code:OnBarUpdate() { if(BarsInProgress == 1) // assuming the secondary series (1) is the smaller timeframe { // all of the code I posted above + your code } }AustinNinjaTrader Customer Service
Comment
-
Thanks Austin for trying to help but it appears to be out of my league so I am going to use the strat I have now and if I like how things are going manually I will pay one of the pros to program it the better way for me.
Thanks again for getting back to me.
Comment
-
Limiting Trades per Bar
It took me a day to figure this out even after reading this thread. An alternative approach without using multi-series time frames (due to the use of countif() in your strategy or for any other reason) is to increment your counter within OnExecution(). Use FirstTickofBar to reset your counter within the same time frame. Within OnExecution() each order fill (buy & sell) is regarded as one count event apiece. Thus, if you want to have 2 trades per bar, the count condition would be
if(tradeCounter < 4)
{ Keep trading....}
Hope this helps...
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
368 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
571 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment