NexusFi: Find Your Edge


Home Menu

 





Counting Consecutive Bars


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

Hi, I would like to count the number of consecutive bars an oscillator spends in oversold before moving back to neutral. And if it has exceeded 8 bars in the oversold zone, to shade the remainder of the bars until it moves back to neutral.

could someone show me how to write the script for the above instructions?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
$4.5M Floods Russia Nuclear Contract in 24 Hours -- Krem …
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
1 thanks
  #2 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 478 since Jun 2009
Thanks Given: 1,419
Thanks Received: 404

what is your basis for overbought/oversold? - stochastic? or some other indicator?
and what settings?
kz


Reply With Quote
  #3 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7


Hi KZ, The basis of overbought/oversold is from an indicator known as TD Range Expansion Index, where overbought > +45 and oversold < -45. I've managed to get that bit done. What I'm trying to add to the indicator now is known as TD Price Oscillator Qualifier which assist to determine the strength of either the oversold or overbought readings.

These indicators are part of tom demark's market timing indicators.


Reply With Quote
  #4 (permalink)
 
hondo69's Avatar
 hondo69 
Austin, TX
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Currencies
Posts: 162 since Jun 2009
Thanks Given: 57
Thanks Received: 248

I think the solution lies in the CountIF statement:

From Ninja help files

if (CountIf(delegate {return Close[0] > Open[0];}, 10) > 8)
EnterLong();

What this is saying is that if the close is greater than the open on more than 8 out of the last 10 bars, enter a long position.

The condition is in blue
if (CountIf(delegate {return Close[0] > Open[0];}, 10) > 8)
EnterLong();


Reply With Quote
Thanked by:
  #5 (permalink)
kaywai
singapore
 
Posts: 131 since Nov 2009
Thanks Given: 11
Thanks Received: 7

Hi Hondo69,

I'm just trying to create the indicator at this point in time. If you see the attached chart, what I want to do is 1) to shade the respective area if the oscillator remains consecutively in oversold/overbought for more than 8 bars.

As my programming skills are almost non-existant, I appreciate all the help that I can get.


Attached Thumbnails
Click image for larger version

Name:	SGXNK 03-10  1_15_2010 (60 Min).jpg
Views:	304
Size:	61.7 KB
ID:	6845  
Reply With Quote




Last Updated on January 17, 2010


© 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