Regards!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Create indicator
Collapse
X
-
Hello U0000999,
Thanks for your post.
You would need to use an integer variable as a counter (one for each type, up/down bar). In coding, you would check to see if the Close is greater than open and if so to increment the Up counter as well as "reset" the down counter to zero. If the Open is greater than the close then increment the down counter and reset the Up counter.
Or if you don't want to reset the counters you could just increment the counters.
Here is a simple example where upCounter and downCounter are created as int at the class level.:
if (Close[0] > Open[0])
{
upCounter++; // increment the up bar counter
}
else if (Close[0] < Open[0])
{
downCounter++; // incrementg the down bar counter
}
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
89 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
47 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
74 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
72 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
60 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment