NexusFi: Find Your Edge


Home Menu

 





CountIf Question


Discussion in NinjaTrader

Updated
    1. trending_up 1,200 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 Fugitive69 
Austin, TX
 
Experience: Intermediate
Platform: NT8
Trading: EU, SP, Crude CL
Posts: 90 since Jul 2018
Thanks Given: 33
Thanks Received: 105

Looking for a better code to use than CountIf.

Say I want to see if the last 8 bars are all "Up" bars then CountIf doesn't really work very well. It only checks to see if within the last X bars Y of them meet the criteria.

 
Code
// If in the last 10 bars we have had 8 up bars then go long
if (CountIf(() => Close[0] > Open[0], 10) > 8)
    EnterLong();
The number of bars to check must be greater than the number that meet the criteria. In the example, the number 10 must be greater than 8.

I want to see if all the bars meet the criteria. Yet when using CountIf I cannot set both variables to 8.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
I developed a free AI-powered (Kronos) forecasting indic …
The Elite Circle
EA
Platforms and Indicators
 




Last Updated on May 9, 2019


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts