Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Builder condition the last second of a one minute bar ninjatrader
Collapse
X
-
Strategy Builder condition the last second of a one minute bar ninjatrader
I want to make a condition on strategy builder that's true on the last second of a one minute bar. I want to do this condition because for some reason my strategy when I test it on Playback it Doesn't open a trade when operated on everytick. When my strategies conditions are met bars ago 1 It should immediately open a trade On the bars ago 0 Which it does perfectly on Strategy Analyzer. But not on playback If I operate my strategy on bar-close, Then it opens the trade, but one bar later Then it should. The only way it works on every tick is if The strategies calculations. And execution is in the same bar o But that ruins my strategy because all those calculations have to be true at the moment of the close of the bar. But I cannot make that work, so the only other way. Is to make a condition. that's only true in the last second of the bar, then My strategy would work. I would appreciate any help or advice I can get. Best regards.Tags: None
-
Hello Szebi,
Thank you for your post.
Unfortunately this cannot be achieved in the Strategy Builder. To achieve this logic, you will need to unlock your code.
In an unlocked script, you can use AddDataSeries() to add a 1-second series to your script, have a condition to check if the BarsInProgress value is equal to the added series and if the Time of the added 1-second series is 1 second before the minute bar closes.
For example:
Code://in OnStateChange(); if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Second, 1); } //in OnBarUpdate() if (BarsInProgress == 1 && Time[0].Second == 59) { //do something }
See the help guide documentation below for more information.
AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm
BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm
Times - https://ninjatrader.com/support/help...ries_times.htm
Multi Time Frames & Instruments - https://ninjatrader.com/support/help...nstruments.htm
Please let me know if you have any other questions.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
116 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
61 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
40 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
43 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
82 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment