Regards!
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
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
}
Paul H.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by percy3687, Today, 12:28 AM
|
0 responses
4 views
0 likes
|
Last Post
by percy3687
Today, 12:28 AM
|
||
Started by sofortune, Yesterday, 11:45 PM
|
1 response
4 views
0 likes
|
Last Post
by sofortune
Yesterday, 11:57 PM
|
||
Started by zzeric, Yesterday, 11:23 PM
|
1 response
4 views
0 likes
|
Last Post Yesterday, 11:34 PM | ||
Started by Pep de lou, Yesterday, 08:14 PM
|
2 responses
20 views
0 likes
|
Last Post
by bltdavid
Yesterday, 08:57 PM
|
||
Started by fingers, 12-15-2023, 08:44 AM
|
6 responses
140 views
0 likes
|
Last Post
by bltdavid
Yesterday, 08:42 PM
|
Comment