Latest News

2022 Start working on a new website

BBS Trading Expert
Watch the Youtube BBS video and here is a crude oil trading example


Want to know more about:

NinjaTrader formulas.

MetaStock formulas.

MetaTrader formulas.

My YouTube videos.

AXIOM business books awards, bronze medal! Thank You!

No longer available!



Favorite articles in 2010, 11, 12, 14 and 2015 S&C Readers' Choice Awards.

readers choice awards

AXIOM Business Books Awards, bronze medal.

AXIOM award






NinjaTrader Formulas

HOME   Back to Ninjatrader Formulas Overview

Smoothed Percent b Oscillator

You're probably familiar with the Percent b (%b, or PB) oscillator that was developed by John Bollinger — it's derived from the Bollinger Bands indicator. Here's how it works: When the price touches the upper Bollinger Band, then the oscillator hits 100. If price moves above the upper band, the oscillator moves to +100. When the price touches the lower Bollinger Band, then the oscillator hits zero, and if price moves below the lower band, the oscillator moves to a negative value. Here's how it's calculated: Percent b = (Closing price – Lower band) / (Upper band – Lower band) * 100

Basic Calculation

When I created my zero-lag oscillator (SVEZLRBPercB), which is based on the Percent b, I used the same basic formula as the Percent b. However, before applying the formula, I manipulated the input data I used. In a July 1997 Stocks & Commodities article, Mel Widner introduced rainbow charts, which is the technique I used to convert the closing price data to a "rainbow" data series and give some extra weight for the less-smoothed data.

Next, I averaged this new rainbow data series with an exponential moving average (EMA) by applying a zero-lag method. The idea of smoothing data with less lag and zero-lag techniques was proposed by Patrick Mulloy in the February 1994 issue of Stocks & Commodities and by John Ehlers in the March 2000 issue. The technique compensates for the lag in moving averages. Finally, I calculate and plot the modified Percent b formula, but only after applying another smoothing step using triple exponential moving averages (TEMA) and weighted moving averages on the zero-lag ZLRB data series.

A full description can be found in the Stocks & Commodities September 2013 publication. You can download the NinjaScript ZIP file below.


Special offer: "Capturing Profit with technical Analysis"

percent_b oscillator

The figure shows the volatility band with the default settings and the SVEZLPercB oscillator.

Special offer: "BBS Band Indicators" DVD

Download the basic NinjaScript formula for this smoothed percent_b oscillator:



HOME   Back to NinjaTrader Formulas Overview


Risk Disclosure: Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones’ financial security or life style. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical Performance Disclosure: Hypothetical performance results have many inherent limitations, some of which are described below. no representation is being made that any account will or is likely to achieve profits or losses similar to those shown; in fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. One of the limitations of hypothetical performance results is that they are generally prepared with the benefit of hindsight. In addition, hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk of actual trading. for example, the ability to withstand losses or to adhere to a particular trading program in spite of trading losses are material points which can also adversely affect actual trading results. There are numerous other factors related to the markets in general or to the implementation of any specific trading program which cannot be fully accounted for in the preparation of hypothetical performance results and all which can adversely affect trading results.

See more 'Legal Disclosures' in the bottom menu bar!

Copyright © 2007, All rights reserved.