Sem BearsBulls
Download scriptThis custom technical indicator, titled "Bears vs. Bulls," is designed to provide visual cues for traders by identifying shifts in market momentum and trend direction. It operates by comparing two primary types of market data: moving averages (which smooth out price action) and "power" metrics that measure the relative strength of buyers (Bulls) versus sellers (Bears).
Core Logic and Mechanism
The script functions by monitoring the relationship between several moving parts on a specific timeframe. Here is how it processes information to generate signals:
1. Trend Analysis (Moving Averages) The tool tracks a primary moving average to determine the general direction of the price. It looks at whether this average is currently climbing or falling compared to its previous position. This helps the script distinguish between an upward-moving trend and a downward-moving trend.
2. Momentum Analysis (Bulls vs. Bears) Simultaneously, the script calculates "Bulls Power" and "Bears Power." These are indicators that measure the strength of buying pressure versus selling pressure. Instead of just looking at where the price is, it looks at who is currently dominating the market—the buyers or the sellers.
3. Signal Generation (The Conflict) The indicator creates specific visual signals when both trend and momentum align in a specific way:
- Bearish Signal: If the moving average is trending downward AND the Bears' power is increasing, the script identifies a bearish condition.
- Bullish Signal: If the moving average is trending upward AND the Bulls' power is increasing, the script identifies a bullish condition.
4. Visual Persistence (The History) One of the unique features of this logic is its "memory." To ensure that signals remain visible on your chart even during periods where the market might be neutral or sideways (where neither bulls nor bears are clearly winning), the script includes a persistence mechanic. If no new signal is generated, the indicator maintains the status of the previous signal. This creates a continuous visual history, allowing traders to see the prevailing sentiment more clearly rather than having signals flicker on and off instantly.
Summary for the Trader
In simple terms, this tool acts as a filter. It doesn't just tell you if the price is going up; it confirms that both the average price trend and the active market momentum are moving in the same direction. By combining these two factors, it aims to highlight high-conviction moves where buyers or sellers have the clear upper hand.
//+------------------------------------------------------------------+
//| Áîëüøàÿ Êîëëåêöèÿ Ñåìàôîðîâ.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ñåðãååâ Àëåêñåé (ñ) 2007"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 4
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1
#property indicator_width4 1
#property indicator_color1 Crimson
#property indicator_color2 LimeGreen
#property indicator_color3 Crimson
#property indicator_color4 LimeGreen
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
#property indicator_style3 STYLE_SOLID
#property indicator_style4 STYLE_SOLID
//---- input parameters
extern int Minutes=0;
extern int MA=20;
extern int MB=13;
extern int Mode=MODE_EMA;//0-sma, 1-ema, 2-smma, 3-lwma
extern int Price=PRICE_CLOSE;//0-close, 1-open, 2-high, 3-low, 4-median, 5-typic, 6-wieight
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexBuffer(3,ExtMapBuffer4);
string Name = "Bears vs. Bulls ("+MA+","+MB+")";
IndicatorShortName(Name);
return(0);
}
int deinit() { return(0); }
int start()
{
double maPre, maCur, bearPre, bearCur, bullPre, bullCur;
//----
for (int i = Bars; i >= 0; i--)
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=0;
maCur=iMA(NULL, Minutes, MA, 0, Mode, Price, i); maPre=iMA(NULL, Minutes, MA, 0, Mode, Price, i+1);
bearCur=iBearsPower(NULL, Minutes, MB, Price, i); bearPre=iBearsPower(NULL, Minutes, MB, Price, i+1);
bullCur=iBullsPower(NULL, Minutes, MB, Price, i); bullPre=iBullsPower(NULL, Minutes, MB, Price, i+1);
if (maCur<maPre && bullCur<bullPre ){ ExtMapBuffer1[i] = 1; }//ïðîäàåì
if (maCur>maPre && bearCur>bearPre ){ ExtMapBuffer2[i] = 1; }//ïîêóïàåì
if (ExtMapBuffer1[i]==0 && ExtMapBuffer2[i] == 0)
{ ExtMapBuffer3[i]=ExtMapBuffer1[i+1]; ExtMapBuffer4[i] = ExtMapBuffer2[i+1]; }
if (ExtMapBuffer3[i]==0 && ExtMapBuffer4[i] == 0 && ExtMapBuffer1[i]==0 && ExtMapBuffer2[i] == 0)
{ ExtMapBuffer3[i]=ExtMapBuffer3[i+1]; ExtMapBuffer4[i] = ExtMapBuffer4[i+1]; }
}
return(0);
}
//+------------------------------------------------------------------+
Comments