How can I get the opening value of the 6:30am bar?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How do I get the value of a bar at a specific time
Collapse
X
-
thanks. i see how that works now, but i'm trying to put it all together.
in this code sample, i'd like to get the difference between the 7:30 opening bar, and the 7:36 opening bar.
the problem is that my openPrice and the thirtySixPrice is the same.
for testing, i ran a backtest on a 1 minute frequency for the previous week.
my output:Code:if (ToTime(Time[0]) >= 73600 && ToTime(Time[0]) < 73700) // ToTime(7, 30, 00)) { int barsAgoOpen = GetBar(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 30, 0)); int barsAgoThirtySix = GetBar(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 36, 0)); double thirtySixPrice = Open[barsAgoThirtySix]; double openPrice = Open[barsAgoOpen]; Print(Time[0].DayOfWeek+" "+openPrice+" "+thirtySixPrice); }Code:Monday 921.5 921.5 Tuesday 921 921 Wednesday 901.5 901.5 Thursday 914.5 914.5 Friday 920.25 920.25
Comment
-
you're right. my barsAgoOpen is always 0. when i increase the time window, it just prints the exact same data for the number of minutes of that window.
are there any ninjascript examples to reference? i've imported a couple from the resource link, but none do what i'm trying to accomplish.
i.e. calculate the difference between minute bars 7:30 and 7:36 and then execute a trade based on that. (obviously the logic wouldn't be that simple, but that would get me to the next step)
Comment
-
Unfortunately I'm not aware any sample more specific than this one - http://www.ninjatrader-support2.com/...ead.php?t=8600
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
635 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
106 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
571 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment