How to build Mcclellan Oscillator in breath Module

Hello everyone,

I want to know, if you guys have a way to build Mcclellan oscillator in the breath module ?

If i build a normal scrpit, then both advanced and declined numbers should be calculated in another breath script?

If that so, then it would be very complicated if we calculated different index datebase.

What is your thought ?


Hi Yan,

Yes you would need to calculate the daily index advance and decline values in the Breadth engine using 2 separate scripts. Once created they can be used in the calculation for the McClellan Oscillator:

(19-day EMA of advances minus declines) - (39 day EMA of advances minus declines)

We calculate those advance/decline numbers for NYSE, Nasdaq and the S&P500 in our Breadth Measures data, so the formula to calculate a Custom Code symbol for the oscillator using would be as follows for the S&P500:

//Get SPX Advance/Decline Data from Breadth Measures data
//Setup 19EMAs on AD Codes
A1 = MA(D1, BARS=19, STYLE=Exponential) ;
A2 = MA(D2, BARS=19, STYLE=Exponential) ;
//Setup 39EMAs on AD Codes
A3 = MA(D1, BARS=39, STYLE=Exponential) ;
A4 = MA(D2, BARS=39, STYLE=Exponential) ;
//Calulate Oscillator
(A1 - A2) - (A3 - A4)


Hi Darren,

Thanks for replying.

I brought up this question because i have a huge breath database which including 30+ sub index and 60+ sectors in China equities market.

I used to look at my Mcclellan oscillator in my Chinese software, which can read easily up and down numbers directly.

So if the software can’t have an special code for that, that would be huge work for every index and sectors.

Maybe we could design a new inner code which can be applied for any database without defining in the new script ?

That would be huge help for me.


Thanks Yan. We are tied up with other projects at the moment so wouldn’t be able to do any custom development work at this time. However, if you have the up and down numbers already calculated and stored in a .csv file then that will make it easier as you won’t need to use the Breadth Engine to calculate them - you would just need to import the .csv files on which to create the oscillator.


Thank you Darren, No worries, i support you guys. Just an idea, i can wait for years, you guys have already done wonderful works, everything would be better in the future. Cheers.

Hi Yan,

The main thing we would need is a clear list of which equities are in each index. Do you know where we can find that? Are there ETFs which copy them?

If we can get the list of what securities are in each index, then we should be able to build the breadth measures.

All the best


Hi Mathew,

I trade mostly in Chinese equities market, which include shanghai composite index, shenzhen composite index and China next index. Since the individual equities in these exchange are not included in the optuma data base, i create extra data folder in optuma by importing data everyday and do breath calculation. It can satisfy my need for now.

For the Mcclellan Oscillator, i use local software which can directly get those upside ticker and downside ticker numbers and it works for me.

Since the quality of Chinese equities data included in optuma default database is very poor(i am sorry but it’s true, the data are not accurate and the majority of them have very short tracking periods ), probably there is no need to build that at all.

If you need any more details, you can let me know.

Have a good day.


lol - I know! Our supplier does not put enough importance on Chinese data. It is something which I want to address later this year.