Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bars in seconds
Collapse
X
-
pman777, there would not be a default function, you would need to take the difference of the bar timestamps and convert to seconds, C# offers a convenient TimeSpan struct for this job - http://www.dotnetperls.com/timespan
Alternatively as starting point you could check into this study from our sharing - http://www.ninjatrader.com/support/f...d=1&linkid=230
-
thanks Bertrand! I will look into those resources. Another related question ... how do I know when a new renko bar has started so I can reset my elapse time counter to start tracking the new bar? Sorry if this is obvious but having an issue figuring this out ... thanks again!
Comment
-
You would go off the Time[0] reference which will give you the timestamp of the current most processed bar, this will update automatically if a new bar starts forming, thus it would update any calculations as well that you base of that. If you process in CalculateOnBarClose = false, then FirstTickOfBar would give you the start of the new bar directly.
Comment
-
I'm making progress ... but one more question
Here's my current code:
if (FirstTickOfBar) barStartTime = DateTime.Now;
barElapsedTime = (DateTime.Now-barStartTime).TotalSeconds;
SecondBar.Set(barElapsedTime);
This is working fine but it only calculates the elapse time of the current bar. How can I get it to calculate the same for prior bars?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by sjsj2732, 03-23-2026, 04:31 AM
|
0 responses
74 views
0 likes
|
Last Post
by sjsj2732
03-23-2026, 04:31 AM
|
||
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
313 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
311 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
148 views
1 like
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
111 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|

Comment