- All Categories
- 2.3K StockCharts
- 385 SharpCharts
- 141 Other Charting Tools
- 67 Saved Charts and ChartLists
- 1.4K Scanning
- 70 Data Issues
- 168 Other StockCharts Questions
- 214 Technical Analysis
- 154 Using Technical Analysis
- 2 InterMarket and International
- 19 Market and Breadth Indicators
- 39 Market Analysis
- 105 Trading
- 105 Trading Strategies
- 159 S.C.A.N the StockCharts Answer Network forum
- 64 Using this StockCharts Answer Network forum
- 95 s.c.a.n. archives
- 17 Off-Topic
- 10 The Cogitation & Rumination Emporium
- 7 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!

0

## 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.