H_Bulls_n_Bears

Download script
Author: Copyright � 2009, MT-Coder.
H_Bulls_n_Bears

This tool is designed to help traders identify which side of the market—the buyers (Bulls) or the sellers (Bears)—currently holds the dominant power. Rather than simply looking at the raw price, this indicator analyzes the relationship between different moving averages to highlight shifts in momentum and market sentiment.

How the Logic Works

The script operates by comparing two distinct layers of data:

  • Short-Term Momentum: It first calculates a fast-moving average that tracks immediate price fluctuations over a very short period.
  • Long-Term Trend: It then calculates a secondary, slower-moving average that represents the broader market trend over a longer duration.

Determining Market Dominance

The core logic of the indicator lies in the mathematical relationship between these two averages. By dividing the short-term data by the long-term data and calculating the difference, the tool produces a visual representation of "strength":

  1. Positive Deviation: When the fast data rises significantly above the slow data, it suggests that the bulls are currently pushing the price upward with strength.
  2. Negative Deviation: When the fast data falls below the slow data, it indicates that the bears have taken control and are driving the market downward.
  3. Neutrality: When the values are close together, it suggests a period of consolidation or equilibrium where neither side has a clear advantage.

Visual Representation

The result is displayed as a histogram in a separate window. This allows you to see the "tug-of-war" between buyers and sellers clearly. By observing the height and direction of the bars, you can more easily identify when a trend is gaining strength or when the market momentum is starting to flip from one side to the other.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
H_Bulls_n_Bears
//+------------------------------------------------------------------+
//|                 This has been coded by MT-Coder                  |
//|                                                                  |
//|                     Email: mt-coder@hotmail.com                  |
//|                      Website: mt-coder.110mb.com                 |
//|                                                                  |
//| For a price I can code for you any strategy you have in mind     |
//|            into EA, I can code any indicator you have in mind    |
//|                                                                  |
//|          Don't hesitate to contact me at mt-coder@hotmail.com    |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|      This indicator trys to indentify the dominanting power in   |
//|            the market.                                           |
//+------------------------------------------------------------------+


#property copyright "Copyright © 2009, MT-Coder."
#property link      "http://mt-coder.110mb.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White

//---- input parameters
extern int HBBPeriod=500;
extern int PeriodOne=2;
extern int PeriodTwo=7;

//---- buffers
double MainBuffer[];
double TempBuffer[];
double TempBufferTwo[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   //---- 1 additional buffer used for counting.
   IndicatorBuffers(3);
   IndicatorDigits(Digits);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,MainBuffer);
   SetIndexBuffer(1,TempBuffer);
   SetIndexBuffer(2,TempBufferTwo);
  
   
//---- name for DataWindow and indicator subwindow label
   short_name="H Bulls n Bears by MT-Coder("+PeriodOne+","+PeriodTwo+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"PeriodOne");
   SetIndexLabel(1,"PeriodTwo");
  
//----
   SetIndexDrawBegin(0,HBBPeriod);
  

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| H Bulls n Bears                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=HBBPeriod) return(0);

//----
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
   for(i=0; i<limit; i++)
      TempBuffer[i]=iMA(NULL,0,PeriodOne,0,MODE_SMA,PRICE_WEIGHTED,i);
//----
//----
   int limito=Bars-counted_bars;
   if(counted_bars>0) limito++;
   for(i=0; i<limito; i++)
      TempBufferTwo[i]=iMA(NULL,0,PeriodTwo,0,MODE_SMA,PRICE_WEIGHTED,i);
//----
   i=Bars-HBBPeriod-1;
   if(counted_bars>=HBBPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {

      MainBuffer[i]=(TempBuffer[i] / TempBufferTwo[i])-1;
      
      //another version
      //MainBuffer[i]=MathPow(TempBuffer[i+PeriodOne],5)/MathPow(TempBuffer[i+PeriodTwo],5); 
      
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments