So if it's 9:37am and I'm using 5min bars, would Close[0] give me the close price at 9:35am?
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
most recent closed bar
Collapse
X
-
Yes I meant to state COBC = true. Then my second part of the question is, with the SMA's for the most recent closed SMA value I would have to use 1 instead of 0 I believe?
So again if it's 9:37am, 5min bars, cobc true, SMA()[1] would give the SMA value at 9:35? Or would I use SMA()[0]?
Comment
-
Zachj,
You would have to switch to COBC false in order to get the current day's high for the scenario you described. If you need to run the rest of the code with COBC set to true, you can use a filter condition for first tick of bar to simulate this -
Code:if(FirstTickOfBar) { //rest of the strategy goes here... }
Cal H.NinjaTrader Customer Service
Comment
-
Zachj,
With the Strategy Analzyer you would not be able to grab that most current bar like with the chart.
However, using an intrabar granularity would be able to help simulate that COBC set to false. Link is below on a reference sample -
http://www.ninjatrader.com/support/f...ead.php?t=6652Cal H.NinjaTrader Customer Service
Comment
-
Ok that's what I figured.
In the guide for CrossAbove they say below that the last bar is 1 that's only if cobc is set to false right? If it was set to true the last bar would be the 0 bar? They don't specify. Just want to make sure I'm solid on this.
// Go long if 10 EMA crosses above 20 EMA within the last bar
if (CrossAbove(EMA(10), EMA(20), 1))
EnterLong();
Comment
-
The last bar is referring the number of bars to look back which must be a minimum of 1 bar. This is because it needs to test when the data series was either greater than or less than that second data series and then the current bar is greater than or less than that second dataseries.
We define a CrossAbvoe as --
Code:if (dataseries1[1] < dataseries 2[1] && dataseries1[0] >= dataseries2[0])
Cal H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by defa0009, Today, 06:44 PM
|
0 responses
1 view
0 likes
|
Last Post
by defa0009
Today, 06:44 PM
|
||
Started by janio973, Today, 06:39 PM
|
0 responses
2 views
0 likes
|
Last Post
by janio973
Today, 06:39 PM
|
||
Started by gusta39, 01-26-2023, 12:22 PM
|
7 responses
228 views
0 likes
|
Last Post
by vpatanka
Today, 05:23 PM
|
||
Started by marioduran5, Today, 04:59 PM
|
0 responses
6 views
0 likes
|
Last Post
by marioduran5
Today, 04:59 PM
|
||
Started by giogio1, Today, 04:23 PM
|
0 responses
9 views
0 likes
|
Last Post
by giogio1
Today, 04:23 PM
|
Comment