Custom Breadth Indicator

Hi,

I’m looking to create a custom breadth thrust indicator that would seem fairly simple, however, I ‘m not having much luck creating it. The indicator is basically the Zweig Breadth thrust model but using the S&P500 data in lieu of the NYSE data. The calculation is (SP500 Advances / SP500 Advances + SP500 Declines). The output data would have a 10 day ema placed on it and presented in Histogram format.

Using the GetData Function, here’s what I have:
GETDATA(CODE=ADVSPX:BM)/GETDATA(CODE=ADVSPX:BM)+GETDATA(CODE=DECSPX:BM)

Not getting desired result from the custom breadth module.

Please advise.

TIA

P.S. I’m moving this post from a custom breadth module tutorial post Darren put up in mid November. So if seen as a dup please disregard.

Hi,

You would not need to build this in custom breadth. As it is a calculation based on existing breadth codes you can use a script with a show view.

The following uses your formula and applies a 10EMA as well…

V1 = GETDATA(CODE=ADVSPX:BM) ;
V2 = GETDATA(CODE=DECSPX:BM) ;
V3 = V1 / V1+V2;
V4 = MA(V3, BARS=10, STYLE=Exponential, CALC=Close) ;
plot1 = V3;
plot1.Plotstyle = Histogram;
plot2 = V4;
plot2.Plotstyle = Line;
plot2.Colour = Red;

One question, with the formula you posted, are you sure it is not meant to be

V3 = V1 / (V1+V2);
?

Matthew,

My mistake, it should in fact be V3= V1/(V1+V2)

Thanks again!

Hello,

Is there a way to script the condition of crossing from below the .40 level to above 0.615 within 10 days on this indicator for the Zweig Breadth Thrust? There is a TimeSinceSignal function, but it would need to to include both levels. Many thanks.

Hi,

You would need to use both the TimeSinceSignal() function and the SignalAfter() function. This script uses the V4 plot for the cross rules, you can change it to V3 if that was what you were after.

V1 = GETDATA(CODE=ADVSPX:BM) ;
V2 = GETDATA(CODE=DECSPX:BM) ;
V3 = V1 / (V1+V2);
V4 = MA(V3, BARS=10, STYLE=Exponential, CALC=Close) ;
//Find the two Cross Criteria
V5 = V4 CrossesBelow 0.40;
V6 = V4 CrossesAbove 0.615;
//Find Time Since V5 Triggered
V7 = TIMESINCESIGNAL(V5) ;
//Find where value crosses above 0.615 after crossing below 0.40 within 10 days
SIGNALAFTER(V5,V6) and V7 <= 10

Here is how it looks on the chart (blue shaded zones):

Ex3