How can I get the opening value of the 6:30am bar?
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
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.
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=8600BertrandNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by suroot, 02-25-2017, 04:43 AM
|
11 responses
2,546 views
0 likes
|
Last Post
by Zilvercat
Today, 05:36 PM
|
||
Started by Rogers101, 05-05-2024, 11:30 AM
|
16 responses
50 views
0 likes
|
Last Post
by Rogers101
Today, 04:44 PM
|
||
Started by ninza33, Today, 12:31 PM
|
2 responses
9 views
0 likes
|
Last Post
by ninza33
Today, 03:52 PM
|
||
Started by Bobin, 03-12-2024, 08:51 AM
|
15 responses
481 views
0 likes
|
Last Post
by fiddich
Today, 03:41 PM
|
||
Started by Skifree, Today, 11:21 AM
|
4 responses
15 views
0 likes
|
Last Post
by Skifree
Today, 03:41 PM
|
Comment