Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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=230BertrandNinjaTrader Customer Service
-
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.BertrandNinjaTrader Customer Service
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
-
You would not want to base it off DateTime.Now for the historical bars, since that would be your current PC clock. Which could not server as a reference for history but only the current moment. You will need to work with Time[x] to access the historical timestamps of the bars for your task.BertrandNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment