Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Comparing bar size
Collapse
X
-
Comparing bar size
Hello, I have a question. I want to compare size of current bar (High [0] – Low [0]) to the size of a previous bar, so it will be possible to condition like ‘open position when current bar longer than previous by 2 ticks’ (I have other conditions, determine what position, long or short). Could you please help me to code this? Thank you -
Hello 2014Michael,
Price series use a BarsAgo index.
For example Close[0] is the close of the most recently updated bar. Close[1] is the close of the previous bar.
To compare the high of the previous bar to be greater than the current bar would be High[1] > High[0].
Below I am providing a link to a forum post with helpful resources on getting started with NinjaScript and C#.
Chelsea B.NinjaTrader Customer Service
-
Hello Chelsea B. thank you for responding. I'm actually did NOT ask how to compare High [1] and High [0]. The question was about how to compare size of a current bar to the size of a previous bar (I'm using OHLC bars). Would be great to know coding
Comment
-
Hello Chelsea B. Could you please give me an example of code of how to compare size of current BAR to the size of a previous Bar? Thank you
Comment
-
Hello Chelea B. Thank you for helping. I'm asking how in code to compare High [0] - Low [0] to High [1] - Low [1] (this is what I meant by size of current bar to size of previous bar). Only this, no volume, no width. Then in condition I would say 'When current bar size bigger than previous bar size by x number of ticks, open position.
Comment
-
Hello 2014Michael,
int TicksExceeded = 4;
if (High[0] - Low[0] > High[1] - Low[1] + TicksExceeded * TickSize)
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.Chelsea B.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
72 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment