NexusFi: Find Your Edge


Home Menu

 





CountIf Question


Discussion in NinjaTrader

Updated
    1. trending_up 1,022 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?
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
The Confluence Meter: A Multi-Layered Signal Framework B …
The Elite Circle
Orban Crashes to 21pct on Record Turnout -- McIlroy Drop …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks




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