Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
time between trades
Collapse
X
-
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?
-
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
-
-
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
- Likes 1
Comment
-
yes, I think you understand me but I still do not get the condition you said how the condition would be like.Originally posted by rockmanx00 View PostYou 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
-
I made it like this but I get 0 trade why? what I need to change ?Originally posted by NinjaTrader_ChelseaB View PostHello 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.1 Photo
Comment
-
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
-
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?Originally posted by NinjaTrader_ChelseaB View PostHello 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-NinjaScriptLast edited by Adamel; 02-27-2025, 02:31 PM.
Comment
-
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 itOriginally posted by NinjaTrader_ChelseaB View PostHello 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?
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
-
now its works the problem was with the single nameOriginally posted by NinjaTrader_ChelseaB View PostHello 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?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
23 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
120 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
63 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
45 views
0 likes
|
Last Post
|

Comment