Thanks.
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
First Bar of Session
Collapse
X
-
Hello Trader17,
When Bars.IsFirstBarOfSession is true, this indicates that a new session has begun and this is the first bar of that session.
The session is based on the Trading Hours template applied to the chart or selected in the Strategy parameters in the Strategy Analyzer / Strategies tab.Chelsea B.NinjaTrader Customer Service
-
Hello Trader17,
I'm not clear on the condition you want.
When you mention "a cross above/below the hi/lo" what is exactly is crossing?
Are you looking for the close of the previous session to be greater than the open of the last bar of the previous session and then less than the low of the first bar of the new session?
This wouldn't work. The close will never be lower than the low. It can only be equal to the low.
You would add two conditions to the condition set. One that the bar is the first bar of the session, second would be the cross condition of whatever two series you are wanting to see cross.Chelsea B.NinjaTrader Customer Service
Comment
-
I am looking for the bid/ask to cross the hi/lo of the first bar of the session. When I tried "Bid crosses first bar of session I got an error. Makes sense as I did not know how to specify the hi/lo of the first bar of the session. The cross can happen anytime during the current session.
Thanks.
Comment
-
Hello Trader17,
The high of the bar is High[0]. The entire high series is High.
The low of the bar is Low[0]. The entire low series is Low.
GetCurrentAsk and GetCurrentBid are not series. These return a snapshot of the current ask or bid price.
The ask and bid are within the high and low (if there is an ask higher than the high, then the high becomes that new ask).
Likely, you will never detect a cross with this.
What code do you have that is causing an error?
The following should compile (though it will never be true):
if (CrossAbove(High, GetCurrentAsk(), 1))
{
// execute code
}Chelsea B.NinjaTrader Customer Service
Comment
-
What I am waiting for is a cross over of the price above the first bar of the session or below the first bar of the session. So I am using on each tick instead of on close in the strategy. So at any point in time during the session if price crosses above/below the hi/lo of the first bar of the session only then we trade that. I only want to focus on the break of the very first bar of the session only. No other bars.
Thanks.
Comment
-
Hello Trader17,
You are trying to save the high of the first bar of the session and then on later bars you are trying to see if the current price has crossed above the high of the first bar of the session?
This would work.
When you say "I am waiting for is a cross over of the price above the first bar of the session" I'm not getting which two objects are being compared.Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello Trader17,
You are trying to save the high of the first bar of the session and then on later bars you are trying to see if the current price has crossed above the high of the first bar of the session?
This would work.
When you say "I am waiting for is a cross over of the price above the first bar of the session" I'm not getting which two objects are being compared.
Thanks.
Comment
-
So I create 2 variables, one for the hi and the other for the low of the first bar of session. Then when price breaks either it trades the break, correct? And the high and low of the first bar of session will always be [0]? And I can use a hi, lo or close of subsequent bars or every price tick to look for the break? I thought when we use on bar close the most recent bar is also [0].
Thanks.
Comment
-
Hello Trader17,
Yes, you would want two variables if you are wanting to store two values (the high and the low).
The currently processing bar will be barsAgo 0. When Bars.IsFirstBarOfSession is true, barsAgo 0 will be the bar you want to save to a variable. On later bars, that bar will no longer be barsAgo 0, which is why you are using that saved variable.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment