How to save to variable first price on the session or first price on the 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 to save first tick of the session or bar.
Collapse
X
-
Hello Czarek,
You can use Bars.IsFirstBarOfSession to know if a bar is the first bar of a session.
You can use IsFirstTickOfBar in real-time when using Calculate as .OnEachTick or .OnPriceChange to know if this is the first tick of the bar.
The link below has examples of setting variables.
Chelsea B.NinjaTrader Customer Service
-
Hello Czarek,
If you are looking at a 10 minute chart, then the first bar of the session would be the first 10 minutes of the trading session. So the ES contracts first bar of session would be the bar with a close time of 5:10PM Chicago time and an open time of 5:00PM. This is Bars.IsFirstBarOfSession.
The first tick of a bar is the first traded price of that bar, which would be the same as the Open of that bar. This is IsFirstTickOfBar.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
-
Hello Czarek,
Thanks for your reply.
To capture the price of the first tick of the first bar of the session, you will need to run your code with the calculate mode Calculate.OnEachTick. You can then capture using:
if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)
{
myvariable = Close[0]; // On a tick basis Close[0] is the price level of the tick
}
Please note that if you are looking at historical data, the above code will return the close value of the bar and not the first tick of the bar because historical data only consists of the OHLC of the finished bar and not of each tick that made up the bar. To see the correct historical tick values you would need to enable Tick Replay or add a 1 tick data series.Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
147 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 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
|
Comment