- 2.5K All Categories
- 2K StockCharts
- 361 SharpCharts
- 111 Other Charting Tools
- 49 Saved Charts and ChartLists
- 1.3K Scanning
- 62 Data Issues
- 149 Other StockCharts Questions
- 183 Technical Analysis
- 133 Using Technical Analysis
- 1 InterMarket and International
- 18 Market and Breadth Indicators
- 31 Market Analysis
- 91 Trading
- 91 Trading Strategies
- 156 S.C.A.N the StockCharts Answer Network forum
- 61 Using this StockCharts Answer Network forum
- 95 s.c.a.n. archives
- 13 Off-Topic
- 9 The Cogitation & Rumination Emporium
- 4 Forum Test Area

New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

in Scanning

This one is a bit complicated but wondering if anyone knows if this is possible. I basically want to see whether the CCI has been above 0 for the majority of the last 120 trading days. I used 80% to give a percentage value to the majority but yeah i was just wondering if such a scan is possible.

Much appreciated!

Much appreciated!

## Comments

There are functions like Count Up ( ) and Count Down( ), and Streak Up ( ) and Streak Down ( ), but I don't think those would do it. The Count functions only deal with the number of times a previous value was higher or lower, and the Streak functions only deal with the number of consecutive values changing in one direction.

The function you want is something like Count Above( ) and Count Below( ), but as far as I know there is no such function, and I don't think there is a way to use existing functions and/or indicators to synthesize them.

That leaves testing each of the 120 bars in various combinations of above and below zero, but the number of combinations, while not infinite, would be considerable, and beyond the character limit of the scan window.

As @markd mentioned, the formula for testing 120 bars would be a bear and probably undesirable. Another option could be to change to weekly or monthly time frames. CCI defaults to 20 days or approximately 1 month. 120 days is approximately 6 months. Still a bear, and I don't know what you are trying to accomplish, but just a thought. If you looked at months 1-5 (ignoring current month 6) a nested code would look at

// at least 4 out of 5 months over 0

and [

[monthly 1-5 >= 0] // 100% above 0

// these lines allow 20% of the months in the range to be less than 0

or [monthly 1-4 >= 0] // allows month 5 to be less than 0

or [[monthly 1-3 >= 0] and [monthly 5 >= 0]] //allows month 4 to be less than 0

or [[monthly 1-2 >= 0] and [monthly 4-5 >= 0]] //allows month 3 to be less than 0

or [[monthly 1 >= 0] and [monthly 3-5 >= 0]] //allows month 2 to be less than 0

or [monthly 2-5 >= 0] // allows month 1 to be less than 0

]

You could include the current month if desired, but remember, the current month isn't final until the last close of the month. Changing to weekly you would employ the same "logic" and be looking at 24 weeks or so and would be a fun exercise in scan code writing.