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 "Bears Power": |
||
function init() { Bears.createParameter("Period", 14); Bears.createBuffer("Bears"); Bears.setBufferColor("Bears", 'red'); Bears.setBufferDrawStyle("Bears", DrawStyle.HISTOGRAM); Bears.setAutoChangeMaxMin("Bears"); Bears.addLevel(0, "white"); } function start() { Bears.label = "Bears(" + Bears.parameter("Period") + ")"; var num = Shared.numberOfQuotes(); var bufSmaClose = Shared.ema(Bears.parameter("Period"), Shared.close()); var bufBears = new Array(num); for (var i = 0; i < num; ++i) { var fValue = Shared.low(i) - bufSmaClose[i]; bufBears[i] = fValue; } Bears.setBufferData("Bears", bufBears); } |