Calculation:

BULLS = HIGH - EMA
BEARS = LOW - EMA

Where:

BULLS - force of bulls;
BEARS - force of bears;
HIGH - maximum price of current bar;
LOW - minimum price of current bar;
EMA - exponential moving average.



Source Code "Bulls Power":

function init()
{
   Bulls.createParameter("Period", 14);

   Bulls.createBuffer("Bulls");
   Bulls.setBufferColor("Bulls", 'lime');
   Bulls.setBufferDrawStyle("Bulls", DrawStyle.HISTOGRAM);
   Bulls.setAutoChangeMaxMin("Bulls");

   Bulls.addLevel(0, "white");
}

function start()
{
   Bulls.label = "Bulls(" + Bulls.parameter("Period") + ")";

   var num = Shared.numberOfQuotes();

   var bufSmaClose =
     Shared.ema(Bulls.parameter("Period"), Shared.close());

   var bufBulls = new Array(num);

   for (var i = 0; i < num; ++i) {
     var fValue = Shared.high(i) - bufSmaClose[i];
     bufBulls[i] = fValue;
   }
   Bulls.setBufferData("Bulls", bufBulls);
}