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 to get price range from first half hour or so of the trading day
Collapse
X
-
As long as you trade an exchange of your timezone that should work. If you trade an exchange outside your timezone (as I usually do) you will face the challenge that there are various daylight savings schedules, which shift the opening period back and forth during the year. In that case you need to collect the information of the correct timezone from the session template under instrument settings to allow for conversion of the exchange time into your local time, for compensating the shift introduced via the daylight savings time.
Leave a comment:
-
Thanks, I found out that class variables are maintained on a per-row basis, which meant that I could use them to store a high and low. Here is the code. The value returned is 1 if the price is above the opening range, -1 if its below the opening range or 0 if its inside the opening range.
public double LowRange = 1000000;
public double HighRange = 0;
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// If we are in the opening range accrue high and low
if (InTimeRange()) {
if (Close[0] < LowRange) LowRange = Close[0];
if (Close[0] > HighRange) HighRange = Close[0];
Plot0.Set(0); // by definition we are still inside the opening range
return;
}
// We are out of the open
if (Close[0] < LowRange) {
Plot0.Set(-1);
return;
}
if (Close[0] > HighRange) {
Plot0.Set(1);
return;
}
Plot0.Set(0);
}
// Collect times between 8:30 to 9 (Central Time)
protected bool InTimeRange() {
if (DateTime.Now.Hour < 8) return false;
if (DateTime.Now.Hour > 9) return false;
if (DateTime.Now.Hour == 8 && DateTime.Now.Minute < 30) return false;
return true;
}
Leave a comment:
-
There are OpeningRange indicators available here which can use the session information and adjust to the open of each instrument.
The best futures trading community on the planet: futures trading, market news, trading charts, trading platforms, trading strategies
The best futures trading community on the planet: futures trading, market news, trading charts, trading platforms, trading strategies
The indicators are available for free download, but forum membership is required. You can also send me a private message with your email, and I will then send you the indicators, as I have written them.
Originally posted by jkmott59 View PostHi all,
I want to compare prices to the opening half hour or so of the day to find out action compared to an opening range.
What would I check for that? If I were to define an indicator's time frame for every 15 minutes I could check the high and low for the first 2 slots if I knew how to retrieve them, but the 0th slot is 'most recent'.
Any suggestions would be appreciated.
JohnLast edited by Harry; 04-14-2012, 08:51 AM.
Leave a comment:
-
Hello,
You can make Time Filters using the ToTime(Time[0]) function.
Please take a look at our reference Sample on Using a time filter to limit trading hours to help you get started:
While this does not illustrate exactly what you wish to do, it should help you give you an idea of how you would get data from a specific time period and how to work with the Time() methods
I would also suggest taking a look at our reference sample on Referencing the correct bar:
Please let me know if you need further assistance.
Leave a comment:
-
How to get price range from first half hour or so of the trading day
Hi all,
I want to compare prices to the opening half hour or so of the day to find out action compared to an opening range.
What would I check for that? If I were to define an indicator's time frame for every 15 minutes I could check the high and low for the first 2 slots if I knew how to retrieve them, but the 0th slot is 'most recent'.
Any suggestions would be appreciated.
JohnTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mattbsea, Today, 05:44 PM
|
0 responses
3 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
31 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
2 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
20 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
Leave a comment: