October 2003
TRADERS' TIPS

Here is this month's selection of Traders' Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues.

You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply "select" the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose "copy" from the browser menu. The copied text can then be "pasted" into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open Web page, data can be transferred with ease.

This month's tips include formulas and programs for:

 
TRADESTATION: Bull And Bear Balance Indicator
METASTOCK: Bull And Bear Balance Indicator
AMIBROKER: Bull And Bear Balance Indicator
eSIGNAL: Bull And Bear Balance Indicator
Wealth-Lab: Bull And Bear Balance Indicator
NEUROSHELL TRADER: Bull And Bear Balance Indicator
NeoTicker: Bull And Bear Balance Indicator
TradingSolutions: Bull And Bear Balance Indicator
AIQ EXPERT DESIGN STUDIO: Bull And Bear Balance Indicator
Investor/RT: Bull And Bear Balance Indicator
Financial Data Calculator: Bull And Bear Balance Indicator


or return to October 2003 Contents


TRADESTATION: Bull And Bear Balance Indicator

Vadim Gimelfarb's article in this issue, "Bull And Bear Balance Indicator," describes a method of deducing market sentiment from close-to-close price movement. His system uses the various possible relationships between the previous close and current open, high, low, and close. Based on the pattern that each day exhibits, the indicator uses a pattern-specific calculation to determine bull and bear strength for the day.

In our code example, his categories are determined with several nested if-then-else statements. While they look a bit complex, they are really just assigning one of 11 bull categories to the day, then calculating the appropriate "bull power." After this is done, the code assigns one of 11 bear categories and does the appropriate bear power calculation.

As predicted by Gimelfarb, the resulting indicator is fairly noisy. He suggests averaging both the bear power and bull power calculations, then subtracting one from the other. Several averages are mentioned, so we have provided two averaging parameters for tweaking the indicator. The first is a length of an exponential average for both bull and bear calculations (the input named "Avg" in the code). The second is a length of an exponential moving average of the difference between bull power and bear power (the input named "Smoothing" in the code). This second average smooths the difference and produces the finished indicator (Figure 1).

Figure 1: TRADESTATION, BULL AND BEAR BALANCE INDICATOR. Here's a sample TradeStation chart demonstrating the smoothed bull and bear balance indicator on the S&P 500 e-mini. The histogram (the red vertical lines) shows the value of the bull and bear indicator at each bar.
Indicator: BullAndBear:
inputs:
 Avg( 20 ),
 Smoothing( 5 ) ;
variables:
 BullPower( 0 ),
 BearPower( 0 ) ;
{Bull Power}
If Close < Open then
 If Close[1] < Open then
  BullPower =
   MaxList(High - Close[1], Close - Low )
 else
  BullPower =
   MaxList(High - Open, Close - Low)
else
 If( Close > Open ) then
  If Close[1] > Open then
   BullPower = High - Low
  else
   BullPower =
    MaxList(Open - Close[1], High - Low )
 else
  If( High - Close > Close - Low ) then
   If Close[1]< Open then
    BullPower = MaxList( High -  Close[1],
     Close - Low )
   else
    BullPower = High - Open
  else
   If High - Close < Close - Low then
    If Close[1] > Open then
     BullPower = High - Low
    else
     BullPower = MaxList(Open - Close[1],
      High - Low )
   else
    If Close[1] > O then
     BullPower = MaxList( High - Open,
      Close - Low )
    else
     If Close[1] < O then
      BullPower = MaxList( Open
       - Close[1], High - Low )
     else
      BullPower = High - Low ;
 
 
If C<O then
 If Close[1]>Open then
  BearPower = MaxList(Close[1]- Open,High - Low )
 else
  BearPower = High - Low
else
 If Close > Open then
  If Close[1] > Open then
   BearPower = Maxlist( Close[1] - Low, High
    - Close)
  else
   BearPower = Maxlist(Open - Low, High
    - Close )
 else
  If High - Close > Close - Low then
   If Close[1] > Open then
    BearPower = MaxList(Close[1]-Open,
     High - Low )
   else
    BearPower = High - Low
  else
   If High - Close < Close - Low then
    If Close[1]>Open then
     BearPower = MaxList(Close[1]-Low,
      High - Close )
    else
     BearPower = Open - Low
   else
    If Close[1]> Open then
     BearPower = MaxList(Close[1]-Open,
      High - Low )
    else
     If Close[1]<O then
      BearPower = MaxList(Open - Low,
       High - Close)
     else
      BearPower = High - Low ;
plot1( Xaverage( XAverage( BullPower, Avg )
 - XAverage( BearPower, Avg ),Smoothing ));


 An indicator based on the BullAndBear indicator code will be available for download from the EasyLanguage Exchange on www.tradestationworld.com. Look for the file "Bull and Bear.eld."

-- Mark Mills, MarkM@TSSec
EasyLanguage Questions Forums
TradeStation Securities, Inc.
www.TradeStationWorld.com


GO BACK


METASTOCK: Bull And Bear Balance Indicator

Vadim Gimelfarb's article in this issue, "Bull And Bear Balance Indicator," references a histogram created by subtracting his bear power indicator from his bull power indicator. The result is then smoothed by a 30-period average. The following formula will reproduce that histogram.

To use this formula in MetaStock, go to Tools | Indicator Builder. Click "New" and enter the name for the formula. Then click in the larger window and enter the actual formula. When done, click OK.  After you plot this formula in a chart, right-click on the resulting line and then left-click "Properties." Change the line style to "Histogram" and click OK.

The formulas for bull power and bear power were rearranged slightly in the hopes of making them easier to read and enter in the formula editor.
 

Name: Bull Power/Bear Power Histogram.
Formula:
r1:=If(Ref(C,-1)<O,Max(O-Ref(C,-1),H-L),H-L);
r2:=If(Ref(C,-1)>O,Max(Ref(C,-1)-O,H-L),H-L);
bull:=If(C=O,
If(H-C=C-L,
If(Ref(C,-1)>O,
  Max(H-O,C-L),
  r1),
If(H-C>C-L,
If(Ref(C,-1)<O,
  Max(H-Ref(C,-1),C-L),
  H-O),
  r1)),
If(C<O,
If(Ref(C,-1)<O,
  Max(H-Ref(C,-1),C-L),
  Max(H-O,C-L)),
  r1));
bear:=If(C=O,
If(H-C=C-L,
If(Ref(C,-1)<O,
  Max(O-L,H-C),
  r2),
If(H-C>C-L,
  r2,
If(Ref(C,-1)>O,
  Max(Ref(C,-1)-L,H-C),
  O-L))),
If(C<O,
  r2,
If(Ref(C,-1)>O,
  Max(Ref(C,-1)-L,H-C),
  Max(O-L,H-C))));
Mov(bull-bear,30,S)
--Scott Brown
Equis International
www.equis.com
 


GO BACK


AMIBROKER: Bull And Bear Balance Indicator

In "Bull And Bear Balance Indicator," Vadim Gimelfarb presents a new indicator that tries to provide good estimation of bull and bear power balance without having the drawbacks of similar well-known indicators such as Elder-ray (by Alexander Elder) and balance of market power (by Igor Livshin). Bull and bear balance indicator (BBB) can be easily reproduced in AmiBroker using its native Afl language.

Listing 1 shows ready-to-use code that can be applied in the AmiBroker Indicator Builder. As suggested by the author, the code first calculates bull and bear powers, then smooths them separately with a 20-day moving average, and then smooths their difference (bull and bear balance) with a 30-day moving average. The smoothing periods can be changed on the fly without modifying the code using the parameters window.
 

LISTING 1
/* Bull-Bear Balance indicator */
BullPower =
IIf( C < O,
IIf( Ref( C, -1 ) < O,
Max( H - Ref( C, -1 ), C - L ),
Max( H - O, C - L ) ),
IIf( C > O,
IIf( Ref( C, -1 ) > O,
H - L,
Max( O - Ref( C, -1 ), H - L ) ),
IIf( H - C > C - L,
IIf( Ref( C, -1 ) < O,
Max( H - Ref( C, -1 ), C - L ),
H - O ),
IIf( H - C < C - L,
IIf( Ref( C, -1 ) > O,
H - L,
Max( O - Ref( C, -1 ), H - L ) ),
IIf( Ref( C, -1 ) > O,
Max( H - O, C - L ),
IIf( Ref( C, -1 ) < O,
Max( O - Ref( C, -1 ), H - L ),
H - L ) ) ) ) ) );
BearPower =
IIf( C < O,
IIf( Ref( C, -1 ) > O,
Max( Ref( C, -1 ) - O, H - L ),
H-L ),
IIf( C > O,
IIf( Ref( C, -1 ) > O,
Max( Ref( C, -1 ) - L, H - C ),
Max( O - L, H - C ) ),
IIf( H - C > C - L,
IIf( Ref( C, -1 ) > O,
Max( Ref( C, -1 ) - O, H - L ),
H - L ),
IIf( H - C < C - L,
IIf( Ref( C, -1 ) > O,
Max( Ref( C, -1 ) - L, H - C ),
O - L ),
IIf( Ref( C, -1 ) > O,
Max( Ref( C, -1 ) - O, H - L ),
IIf( Ref( C, -1 ) < O,
Max( O - L, H - C ),
H - L ) ) ) ) ) );
s1=Param("Smooth 1", 20, 1, 100 );
s2=Param("Smooth 2", 30, 1, 100 );
SmoothBBB= MA(EMA( BullPower,s1)-EMA( BearPower,s1),s2);
Caption = "Smoothed BBB ( " + s1 + ", " + s2 + " ) ";
Plot( SmoothBBB, Caption, colorBlue, styleHistogram );


A downloadable version of this formula is available from AmiBroker's website. Figure 2 shows the bull-bear balance (BBB) indicator plotted on Barr Laboratories.
 


FIGURE 2: AMIBROKER, Bull-Bear Balance. This AmiBroker chart shows a daily Barr Laboratories chart and the double-smoothed bull-bear balance (BBB) indicator (lower pane). The negative divergence between price action and BBB shows clearly that the uptrend is ending.
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
GO BACK

eSIGNAL: Bull And Bear Balance Indicator

We have coded the indicators described by Vadim Gimelfarb in this issue in "Bull And Bear Balance Indicator." Based on the article, there are different ways of constructing the indicator graph: 1) as two graphs, corresponding to the bull and bear powers; and 2) as a histogram representing the difference between the two powers (the power balance). Thus, here are three sets of code: BBB (bull power), BBB (bear power), and BBB as a histogram.
 

/*******************************************************************
Description : This Study Plots Bull and Bear Balance Indicator (Bull Power - Bear Power)
Provided By : TS Support, LLC for eSignal
********************************************************************/
function preMain(){
    setStudyTitle("BBB");
    setCursorLabelName("BBB",0);
    setDefaultBarFgColor(Color.red,0);
    setDefaultBarFgColor(Color.brown,1);
    setComputeOnClose();
    setPlotType(PLOTTYPE_HISTOGRAM,0);
}
function main(){
 var value = 0;
 value = callFunction("bull_power.efs", "main") - callFunction("bear_power.efs", "main");
 if(value < 0)
  setDefaultBarFgColor(Color.red,0);
 else
  setDefaultBarFgColor(Color.blue,0);
 return new Array(value,value);
}
/*******************************************************************
Description : This Study Plots Bull and Bear Balance Indicator (Bear Power)
Provided By : TS Support, LLC for eSignal
********************************************************************/
function preMain(){
    setStudyTitle("BBB Bear Power");
    setCursorLabelName("Bear Power",0);
    setDefaultBarFgColor(Color.red,0);
    setComputeOnClose();
    setDefaultBarThickness(2);
}
function main(){
 
 var value = 0;
 
 if(close() < open())
  if(close(-1) > open())
   value = Math.max(close(-1) - open(), high() - low());
  else
   value = high() - low();
 else
  if (close() > open())
   if(close(-1) > open())
    value = Math.max(close(-1) - low(), high() - close());
   else
    value = Math.max(open() - low(),high() - close());
  else
   if(high() - close() > close() - low())
    if(close(-1) > open())
     value = Math.max(close(-1) - open(),high() - low());
    else
     value = high() - low();
   else
    if(high() - close() < close() - low())
     if(close(-1) > open())
      value = Math.max(close(-1) - low(),high() - close());
     else
      value = open() - low();
    else
     if(close(-1) > open())
      value = Math.max(close(-1) - open(),high() - low());
     else
      if(close(-1) < open())
       value = Math.max(open() - low(),high() - close());
      else
       value = high() - low();
 return value;
}
/*******************************************************************
Description : This Study Plots Bull and Bear Balance Indicator (Bull Power)
Provided By : TS Support, LLC for eSignal
********************************************************************/
function preMain(){
    setStudyTitle("BBB Bull Power");
    setCursorLabelName("Bull Power",0);
    setDefaultBarFgColor(Color.blue,0);
    setComputeOnClose();
    setDefaultBarThickness(2);
}
function main(){
 
 var value = 0;
 
 if(close() < open())
  if(close(-1) < open())
   value = Math.max(high() - close(-1), close() - low());
  else
   value = Math.max(high() - open(), close() - low());
 else
  if (close() > open())
   if(close(-1) > open())
    value = high() - low();
   else
    value = Math.max(open() - close(-1),high() - low());
  else
   if(high() - close() > close() - low())
    if(close(-1) < open())
     value = Math.max(high() - close(-1),close() - low());
    else
     value = high() - open();
   else
    if(high() - close() < close() - low())
     if(close(-1) > open())
      value = high() - low();
     else
      value = Math.max(open() - close(-1),high() - low());
    else
     if(close(-1) > open())
      value = Math.max(high() - open(),close() - low());
     else
      if(close(-1) < open())
       value = Math.max(open() - close(-1),high() - low());
      else
       value = high() - low();
 return value;
}
--eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignal.com
GO BACK

Wealth-Lab: Bull And Bear Balance Indicator

The BullPower and BearPower indicators presented in "Bull And Bear Balance Indicator" by Vadim Gimelfarb this month are available for use on the Wealth-Lab.com website, as well as for download into Wealth-Lab Developer.

To avoid confusion with the Elder indicators, we have renamed these indicators BullPowerVG and BearPowerVG. We also present a trading system based on the interpretation suggested in the article. We smoothed the bull and bear powers with a 20-bar moving average, then smoothed the resulting BBB indicator with a 30-bar moving average. A buy signal occurs when Bbb turns up from below zero, and a sell signal occurs when BBB turns down from above zero.

A sample trade can be seen in Figure 3. The green BBB histogram bar indicates where the indicator turned up from below zero. Note that this wasn't the true bottom of the BBB; it continued lower. One way to minimize premature signals is to use a signal line, such as a nine-period EMA of the BBB. The entry signal would occur when BBB crosses above the signal line.

FIGURE 3: Wealth-Lab, BULL AND BEAR BALANCE INDICATOR. This sample Wealth-Lab chart shows a sample trade using the BullPowerVG and BearPowerVG indicators smoothed first with a 20-bar moving average then a 30-bar moving average. A buy signal occurs when BBB turns up from below zero, and a sell signal when BBB turns down from above zero.


Another sample trade on Apple Computer can be seen in Figure 4. The system did exceptionally well on Apple, logging 30 out of 44 winning trades, and beating buy and hold at all levels. We next tested the system on a portfolio of the 30 Dow Jones industrials over a four-year period. Each trade was sized so that it would equal 4% of the current portfolio equity level. The system was profitable, returning a 5.93% profit, while a buy and hold strategy returned a loss of -19.37% for the same testing period  (Figure 5).

FIGURE 4: Wealth-Lab, BULL AND BEAR SYSTEM. This sample Wealth-Lab chart shows a trade on Apple Computer using the smoothed BullPowerVG and BearPowerVG indicators as a trading system. The system did exceptionally well on Apple, logging 30 out of 44 winning trades, and beating buy and hold at all levels.
 


FIGURE 5: Wealth-Lab, BULL AND BEAR SYSTEM. This sample Wealth-Lab chart shows the system on a portfolio of the 30 Dow Jones industrials over a four-year period. The system was profitable, returning a 5.93% profit, while a buy and hold strategy returned a loss of -19.37% for the same testing period.

This system represents the most basic implementation of the ideas presented. Some potential improvements might include adjusting the smoothing factors to reduce the lag and increase the responsiveness of the system; applying a stop-loss and possibly a profit target; and adjusting the exit so that the system captures profits more quickly instead of waiting for a substantial decline.
 
{$I  'BearPowerVG'}
{$I 'BullPowerVG'}
const  SmoothBullBear = 20;
const SmoothBBB = 30;
var Bar,  BullPane: integer;
var BullPowerVG1, BearPowerVG1: integer;
var BBB,  BBBPane: integer;
{ Create  Custom Chart Panes }
BullPane := CreatePane( 75, true, true );
BBBPane :=  CreatePane( 150, true, true );
{ Obtain and  Plot the BullPower and BearPower, smoothed }
BullPowerVG1 := SMASeries(  BullPowerVGSeries, SmoothBullBear );
PlotSeriesLabel( BullPowerVG1, BullPane,  050, #Thick, 'BullPower' );
BearPowerVG1 := SMASeries( BearPowerVGSeries,  SmoothBullBear );
PlotSeriesLabel( BearPowerVG1, BullPane, 900, #Thick,  'BearPower' );
{Calculate and Plot the smoothed BBB indicator }
BBB := SMASeries( SubtractSeries(  BullPowerVG1, BearPowerVG1 ), SmoothBBB );
PlotSeriesLabel( BBB, BBBPane,  #Navy, #ThickHist, 'BBB' );   { Implement
trading system rules }
for Bar := 60 to  BarCount - 1 do
begin
  SetSeriesBarColor( Bar, BBB, #Navy  );
  if MarketPosition = 0 then
  begin
    if  @BBB[Bar] < 0 then
      if TurnUp( Bar, BBB )  then
       begin
        SetSeriesBarColor( Bar, BBB,  #Lime );
        BuyAtMarket( Bar + 1, ''  );
      end;
  end
  else
   begin
    if @BBB[Bar] > 0  then
      if TurnDown( Bar, BBB )  then
       begin
        SetSeriesBarColor( Bar, BBB,  #Red );
        SellAtMarket( Bar + 1,  LastPosition, '' );
      end;
   end;
end;
--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com

 
 

GO BACK


NEUROSHELL TRADER: Bull And Bear Balance Indicator

To recreate Vadim Gimelfarb's bull and bear power indicators in NeuroShell Trader, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create the following intermediate indicators:
 

COND1 = A<B( Close, Open )
COND2 = A>B( Close, Open )
COND3 = A<B( Lag(Close,1), Open )
COND4 = A>B( Lag(Close,1), Open )
COND5 = A<B( Subtract( High, Close ), Subtract( Close, Low ) )
COND6 = A>B( Subtract( High, Close ), Subtract( Close, Low ) )
BULL1 = Subtract( High, Low )
BULL2 = Subtract( High, Open )
BULL3 = Max2( BULL2, Subtract( Close, Low ) )
BULL4 = Max2( Subtract( Open, Lag(Close,1) ), BULL1 )
BULL5 = Max2( Subtract( High, Lag(Close,1) ), Subtract( Close, Low ) )
BEAR1 = Subtract( High, Low )
BEAR2 = Subtract( Open, Low )
BEAR3 = Max2( BEAR2, Subtract( High, Close ) )
BEAR4 = Max2( Subtract( Lag(Close,1), Open ), BEAR1 )
BEAR5 = Max2( Subtract( Lag(Close,1), Low ), Subtract( High, Close ) )


To recreate the actual bull power, bear power, and Bbb indicators, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create the following indicators:
 

BULLPOWER = IfThenElseIfThen(
     COND1,
     IfThenElse (COND3, BULL5, BULL3),
     COND2,
     IfThenElse (COND4, BULL1, BULL4),
     IfThenElseIfThen (
          COND6,
          IfThenElse (COND3, BULL5, BULL2),
          COND5,
          IfThenElse (COND4, BULL1, BULL4),
          IfThenElseIfThen ( COND4, BULL3, COND3, BULL4, BULL1)))
BEARPOWER = IfThenElseIfThen (
     COND1,
     IfThenElse (COND4, BEAR4, BEAR1),
     COND2,
     IfThenElse (COND4, BEAR5, BEAR3),
     IfThenElseElseIfThen (
          COND6,
          IfThenElse (COND4, BEAR4, BEAR1),
          COND5,
          IfThenElse (COND4, BEAR5, BEAR2),
          IfThenElseIfThen( COND4, BEAR4, COND3, BEAR3, BEAR1)))
BBB = ExpAvg( Subtract( ExpAvg(BULLPOWER,20), ExpAvg(BEARPOWER,20) ), 30 )


Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a sample chart that includes the bull power, bear power, and BBB custom indicators (Figure 6).
 


Figure 6: NEUROSHELL TRADER, BULL AND BEAR BALANCE INDICATORS. Here's a sample NeuroShell Trader chart demonstrating the bull and bear power indicators.


For more information on NeuroShell Trader, visit www.NeuroShell.com.

--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com


GO BACK


NeoTicker: Bull And Bear Balance Indicator

The bull power and bear power indicators presented in "Bull And Bear Balance Indicator" by Vadim Gimelfarb in this issue can be implemented in NeoTicker using formula language.

To recreate the bull power formula indicator, open a new script editor window. Select Indicator>Setup from the menu to open the indicator definition setup window. Set the indicator type to "Formula." Under the Pane Option tab, set the Indicator Placement to "New Pane." Next, enter the formula (Listing 1), and then simply verify and install.

To recreate the bear power formula indicator, open another script editor window. Repeat the same steps as the ones for the bull power indicator. Enter the formula (Listing 2), then verify and install.

To apply the two indicators to a chart (Figure 7), first load a daily chart, say, symbol BRL. Then select the BRL data series, and add the bull power indicator to it. Repeat the same process with the bear power indicator.
 
 

FIGURE 7: NEOTICKER, BULL AND BEAR POWER INDICATORS. Here's a sample chart showing the bull power indicator and the bear power indicator in NeoTicker.


Downloadable versions of these indicators will be available from the TickQuest website.
 

LISTING 1
plot1 := if(c<o,
         if(c(1)<o,
            max(h-c(1),c-l),
            max(h-o,c-l)),
         if(c>o,
         if(c(1)>o,
            h-l,
            max(o-c(1),h-l)),
         if((h-c)>(c-l),
         if(c(1)<o,
            max(h-c(1),c-l),
            h-o),
         if((h-c)<(c-l),
         if(c(1)>o,
            h-l,
            max(o-c(1),h-l)),
         if(c(1)>o,
            max(h-o,c-l),
         if(c(1)<o,
            max(o-c(1),h-l),
            h-l))))));
LISTING 2
plot1 := if(c<o,
         if(c(1)>o,
            max(c(1)-o,h-l),
            h-l),
         if(c>o,
         if(c(1)>o,
            max(c(1)-l,h-c),
            max(o-l,h-c)),
         if((h-c)>(c-l),
         if(c(1)>o,
            max(c(1)-o,h-l),
            h-l),
         if((h-c)<(c-l),
         if(c(1)>o,
            max(c(1)-l,h-c),
            o-l),
         if(c(1)>o,
            max(c(1)-o,h-l),
         if(c(1)<o,
            max(o-l,h-c),
            h-l))))));
--Kenneth Yuen, TickQuest Inc.
www.tickquest.com


GO BACK


TradingSolutions: Bull And Bear Balance Indicator

In his article "Bull And Bear Balance Indicator," Vadim Gimelfarb presents calculations for the relative power associated with bulls and bears. The calculations are based on checking for a variety of conditions and returning the appropriate difference for the condition. They can be entered into TradingSolutions as follows:
 

Name: BBB Bull Power
Short Name: BullPower
Inputs: Close, Open, High, Low
Formula:
If (LT (Close,Open),If (LT (Lag (Close,1),Open),Max (Sub (High,Lag (Close,1)),
 Sub (Close,Low)),Max (Sub (High,Open),Sub (Close,Low))),If (GT (Close,Open),
 If (GT (Lag (Close,1),Open),Sub (High,Low),Max (Sub (Open,Lag (Close,1)),
 Sub (High,Low))),If (GT (Sub (High,Close),Sub (Close,Low)),
 If (LT (Lag (Close,1),Open),Max (Sub (High,Lag (Close,1)),Sub (Close,Low)),
 Sub (High,Open)),If (LT (Sub (High,Close),Sub (Close,Low)),
 If (GT (Lag (Close,1),Open),Sub (High,Low),Max (Sub (Open,Lag (Close,1)),
 Sub (High,Low))),If (GT (Lag (Close,1),Open),Max (Sub (High,Open),
 Sub (Close,Low)),If (LT (Lag (Close,1),Open),Max (Sub (Open,Lag (Close,1)),
 Sub (High,Low)),Sub (High,Low)))))))
Name: BBB Bear Power
Short Name: BearPower
Inputs: Close, Open, High, Low
Formula:
If (LT (Close,Open),If (GT (Lag (Close,1),Open),Max (Sub (Lag (Close,1),Open),
 Sub (High,Low)),Sub (High,Low)),If (GT (Close,Open),If (GT (Lag (Close,1),Open),
 Max (Sub (Lag (Close,1),Low),Sub (High,Close)),Max (Sub (Open,Low),
 Sub (High,Close))),If (GT (Sub (High,Close),Sub (Close,Low)),
 If (GT (Lag (Close,1),Open),Max (Sub (Lag (Close,1),Open),Sub (High,Low)),
 Sub (High,Low)),If (LT (Sub (High,Close),Sub (Close,Low)),
 If (GT (Lag (Close,1),Open),Max (Sub (Lag (Close,1),Low),Sub (High,Close)),
 Sub (Open,Low)),If (GT (Lag (Close,1),Open),Max (Sub (Lag (Close,1),Open),
 Sub (High,Low)),If (LT (Lag (Close,1),Open),Max (Sub (Open,Low),
 Sub (High,Close)),Sub (High,Low)))))))


These functions are available in a function file that can be downloaded from the TradingSolutions website (www.tradingsolutions.com) in the Solution Library section.

As with many indicators, functions such as bull and bear power can make good inputs to neural network predictions. If used directly, you will want to set the preprocessing to "None," since the value stays primarily within a specific range, or to "Change" if the momentum of the indicator is desired.

--Gary Geniesse, NeuroDimension, Inc.
800 634-3327, 352 377-5144
www.tradingsolutions.com


GO BACK


AIQ EXPERT DESIGN STUDIO: Bull And Bear Balance Indicator

Here is the code for use in AIQ's Expert Design Studio based on "Bull And Bear Balance Indicator" by Vadim Gimelfarb in this issue. A sample chart is shown in Figure 8.

FIGURE 8: AIQ, BULL AND BEAR POWER. Here's a sample AIQ chart showing the bull and bear balance indicator (BBB).
! BBB Indicator
! Coded by Rich Denning 8/14/03
! Stocks & Commodities October 2003.
!  A 20/30 period exponential smoothing was used, as the article
! did not specify the type of smoothing.
C is [close].
C1 is val([close],1).
O is [open].
H is [high].
L is [low].
BullPwr is iff(C<O,
     iff(C1<O,
        max(H-C1,C-L),
        max(H-O,C-L)),
                iff(C>O,
   iff(C1>O,
        H-L,
        max(O-C1,H-L)),
               iff(H-C>C-L,
   iff(C1<O,
         max(H-C1,C-L),
         H-O),
              iff(H-C<C-L,
  iff(C1>O,
         H-L,
         max(O-C1,H-L)),
              iff(C1>O,
         max(H-O,C-L),
              iff(C1<O,
         max(O-C1,H-L),
         H-L)))))).
BearPwr is iff(C<O,
     iff(C1>O,
        max(C1-O,H-L),
        H-L),
                    iff(C>O,
       iff(C1>O,
          max(C1-L,H-C),
           max(O-L,H-C)),
     iff(H-C>C-L,
       iff(C1>O,
         max(C1-O,H-L),
         H-L),
      iff(H-C<C-L,
        iff(C1>O,
           max(C1-L,H-C),
           O-L),
       iff(C1>O,
         max(C1-O,H-L),
                     iff(C1<O,
         max(O-L,H-C),
         H-L)))))).
BBB is expavg(expavg(BullPwr,20) - expavg(BearPwr,20),30).
--Mike Kaden
Aiq Systems
www.aiq.com


GO BACK


Investor/RT: Bull And Bear Balance Indicator

Vadim Gimelfarb's bull and bear balance indicator (BBB) described in this issue is based on the difference between the bull power and bear power. He uses a unique method for computing the bull and bear power, which is path-dependent and incorporates the previous day's closing price in the computation.

Investor/RT's bull power and bear power indicators now provide an option for computing the result using Gimelfarb's unique method, along with options for using the Elder-ray and Livshin methods, which are also discussed in Gimelfarb's article.

Figure 9 shows the bull power and bear power indicators in the middle pane, along with the BBB indicator in the lower pane. The bull and bear power indicators both use the same preferences, displayed in Figure 10. In this case, the Gimelfarb method was used to compute the powers. A 20-period simple moving average was used to smooth the resulting raw values. Both are drawn using the "custom histogram" drawing style, which allows multiple histograms to be overlaid (and offset horizontally) in the same pane.

Figure 9: Investor/RT, BULL POWER AND BEAR POWER. This Investor/RT daily candlestick chart of MSFT shows bull power (green) and bear power (red) indicators in the middle pane (drawn as custom histograms) along with the BBB custom indicator in the lower pane.


The BBB indicator is created using a custom indicator, which takes the difference between the bull and bear power values, and then applies a 30-period simple moving average to the results. The syntax for this BBB custom indicator is simply:
 

MA(BULLP / BEARP)


The three tokens used are self-explanatory. The BullP and BearP preferences should match those seen in Figure 10. The moving average (MA) preferences would be set up with a period of 30, and a type of "Simple."

Figure 10: Investor/RT, BULL AND BEAR POWER indicator PREFERENCE SETTINGS. Here are the preferences used for the bull power and bear power indicators. The Gimelfarb method is chosen, and the raw values are smoothed with a 20-period simple moving average.
Gimelfarb recommends buying when the BBB indicator crosses above zero, and selling when it crosses below zero. Signal markers are added to the chart in Figure 9, showing a green up arrow for buy signals, and a red down arrow for sell signals.

Any Investor/RT user can quickly import the chart seen in Figure 9 by visiting the following web page:

https://www.linnsoft.com/charts/

By importing the chart, the user will also import the custom indicators required to create the BBB, along with the signal markers that mark the bars on which a buy or sell should be initiated. The size, colors, symbol, indicators, scaling properties, and all other characteristics of the chart will also be reflected on the imported chart.

Related links:
https://www.linnsoft.com/tour/techind/bull.htm
https://www.linnsoft.com/tour/techind/bear.htm
https://www.linnsoft.com/tour/customIndicator.htm
https://www.linnsoft.com/tour/techind/movAvg.htm

--Chad Payne, Linn Software
800-546-6842, info@linnsoft.com
www.linnsoft.com


GO BACK


Financial Data Calculator: Bull And Bear Balance Indicator

The article "Bull And Bear Balance Indicator" by Vadim Gimelfarb introduces the indicators bull power, bear power, and BBB (which is the indicator referenced in the article's title). These indicators can be programmed as macros in FDC as follows:

Open the macro wizard, choose "New macro," and enter the following code into the definition window:
 

O: open #R
H: high #R
L: low #R
C: close #R
PrevC: close #R back 1
L1: C < O
L2: C > O
L3: (C = O) and (C < midrange #R)
L4: (C = O) and (C > midrange #R)
L5: (C = O) and (C = midrange #R) and O < PrevC
L6: (C = O) and (C = midrange #R) and O >= PrevC
A: L1 or L3 or L5
B: L2 or L4 or L6
X: O min PrevC
P1: (H - X) max (C - L)
P2: (O - PrevC) max (H - L)
(P1 when A) merge (P2 when B)


This macro is then saved under the name "bullpower." The macro can have a more compact form, but using intermediate abbreviations to the left of the colons aids readability. The final line defines the bullpower, and is applied to a dataset, for example, snp, by executing the phrase "bullpower snp" in a command line.

Similarly, to form the bear power macro, open the macro wizard, choose "New macro," and enter the following code into the definition window:
 

O: open #R
H: high #R
L: low #R
C: close #R
PrevC: close #R back 1
L1: C < O
L2: C > O
L3: (C = O) and (C < midrange #R)
L4: (C = O) and (C > midrange #R)
L5: (C = O) and (C = midrange #R) and O <= PrevC
L6: (C = O) and (C = midrange #R) and O > PrevC
A: L1 or L3 or L5
B: L2 or L4 or L6
X: O max PrevC
P1: (PrevC - O) max (H - L)
P2: (X - L) max (H - C)
(P1 when A) merge (P2 when B)


This macro is then saved under the name "bearpower." The final macro is produced by choosing "New macro" in the macro wizard, entering the  code:

Bullpower #R / Bearpower #R

and saving the result as the macro BBB.

-- Robert Busby
Futures Software Associates, Inc.
856 857-9088, www.financialdatacalculator.com
GO BACK

All rights reserved. © Copyright 2003, Technical Analysis, Inc.


Return to October 2003 Contents