I am trying to build a strategy that finds the high and low from a fifteen minute period and then takes a trade if the current 1 minute bar closes above that high. How would I use a 1 minute dataseries but get the high and low from the fifteen minute 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
Find the high and low of fifteen minute bar in a 1 minute chart
Collapse
X
-
Find the high and low of fifteen minute bar in a 1 minute chart
Hey NinjaTrader team,
I am trying to build a strategy that finds the high and low from a fifteen minute period and then takes a trade if the current 1 minute bar closes above that high. How would I use a 1 minute dataseries but get the high and low from the fifteen minute bar?Tags: None
-
Hello Jonathan.Lee,
If you specifically wanted to know the High/Low of the last 15 minute bar you can add a secondary series and then access the High and Low of the last bar:
If you wanted to know the High/Low of the last 15 1 minute bars you could use the Highest and LowestBar methods:
instead of using the BarsSinceNewTradingDay in the sample you could use 15 or the last 15 bars.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
Awesome that worked. I have one more question:
After finding the high and low of the last fifteen minute bar I would like to limit my limit order to a time frame of 12 minute after the close of the last fifteen minute bar. How could I do that?
Comment
-
Hello Jonathan.Lee,
That would likely be easiest by adding a secondary series of 15 minutes to control resetting a variable. Because there is not a specific 15 minute bar with a 1 minute series you could add another series to reset a variable.
Your minute series can use a integer to count 12 minute bars and start doing the action once you reach that point. The 15 minute series could be used to reset it.
A very simplistic example would be like the following:
Code:private int counter; protected override void OnBarUpdate() { if(BarsInProgress == 0) //assuming this is on the 15 minute primary { counter = 0; } if(BarsInProgress == 1) //assuming this is on the 1 minute secondary { if(counter >= 12) { } counter++; } }
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
I have this bit of code trying to get the high and low of the last fifteen minute bar, but it seems to give me info from the current bar. How do I get the high and low from the last bar that closed and not the current bar that is open?
if (BarsInProgress == 1)
{
fifteenMinuteHigh = MAX(High, 1)[0];
Print("Fifteen Minute High is " + fifteenMinuteHigh + " " + Time[0].ToString());
fifteenMinuteLow = MIN(Low, 1)[0];
Print("Fifteen Minute Low is " + fifteenMinuteLow + " " + Time[0].ToString());
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jourdale, 03-16-2024, 06:33 AM
|
3 responses
40 views
0 likes
|
Last Post Today, 06:44 PM | ||
Started by henryd333, 03-22-2021, 08:18 AM
|
18 responses
930 views
0 likes
|
Last Post Today, 06:07 PM | ||
Started by PaulMohn, Today, 05:51 PM
|
0 responses
4 views
0 likes
|
Last Post
by PaulMohn
Today, 05:51 PM
|
||
Started by johnathanhebert, 03-01-2024, 05:38 PM
|
8 responses
60 views
0 likes
|
Last Post Today, 05:48 PM | ||
Started by endystrike, 12-06-2016, 09:52 AM
|
144 responses
8,611 views
0 likes
|
Last Post
by bobperez
Today, 04:08 PM
|
Comment