NexusFi: Find Your Edge


Home Menu

 





CountIf Question


Discussion in NinjaTrader

Updated
    1. trending_up 1,105 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?
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
CPI Eve: Fed Hike Odds Hold at 52% for the First Time, I …
Prediction Markets & Event Contracts
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
3 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