By analogy with the MQL: iTime (_Symbol, _Period, 0) gives the opening time of the current bar. Is there anything similar in the NS?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to find the bars Opening time?
Collapse
X
-
How to find the bars Opening time?
Time[0] gives the closing time of the bar. How to find out the time when this bar appeared on the chart (time of its opening)?
By analogy with the MQL: iTime (_Symbol, _Period, 0) gives the opening time of the current bar. Is there anything similar in the NS?Tags: None
-
Hello webus,
Thanks for your post and welcome to the NinjaTrader Forums!
Ninjatrader does timestamp the end of the bar, other platforms timestamp the beginning of the bar.
The beginning of the bar would be relatively the same time as the end of the previous bar. So the start time of the current bar would be equal to Time[0] - (Time[0] - Time[1]). Here is a print statement you could use to see this: Print ("Bar Start time: "+(Time[0] -(Time[0] - Time[1])).ToString()+ " Bar End time: "+Time[0]);
A more precise way, on real time data, would be to add a 1 tick series and use Bars.IsFirstTickOfBar on the primary series and collect the time from the tick series bar.
Reference: https://ninjatrader.com/support/help...ttickofbar.htmPaul H.NinjaTrader Customer Service
-
Originally posted by NinjaTrader_PaulH View PostHello webus,
The beginning of the bar would be relatively the same time as the end of the previous bar. So the start time of the current bar would be equal to Time[0] - (Time[0] - Time[1]). Here is a print statement you could use to see this: Print ("Bar Start time: "+(Time[0] -(Time[0] - Time[1])).ToString()+ " Bar End time: "+Time[0]);
I think I can not agree with you.
For example, chart Minute 1. The trading week closed on Friday at 23:59 (closing time of the last bar). A new week began on Monday at 00:00 (00:01 the closing time of the first bar).
According to your formula, the opening time of the first bar on Monday is Friday 23:59. This is not true and not what I need.
I want to get 00:00 Monday in this case.
- Likes 1
Comment
-
Hello webus,
Thanks for your reply.
If you are using time based bars (I was assuming you were not using time based bars), then (in the case of 1 minute bars) you can subtract 1 minute from the bars time stamp. Print ("Start time of bar: "+Time[0].AddMinutes(-1)+" End of Bar: "+Time[0]);Paul H.NinjaTrader Customer Service
- Likes 1
Comment
-
Originally posted by NinjaTrader_PaulH View PostHello webus,
Thanks for your reply.
If you are using time based bars (I was assuming you were not using time based bars), then (in the case of 1 minute bars) you can subtract 1 minute from the bars time stamp. Print ("Start time of bar: "+Time[0].AddMinutes(-1)+" End of Bar: "+Time[0]);
Thanks for the answer. At the moment I am using the same method. I thought that there is some more universal method (something like a dataseries).
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
53 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
33 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
5 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment