This custom indicator is designed to analyze price action by identifying specific zones of market "overextension" relative to a moving average. It acts as a visual signal tool that helps traders distinguish between strong trends and periods where the price is beginning to lose momentum.
Core Logic and Functionality
The tool operates by calculating an "Envelope"—a boundary system based on a chosen moving average (which can be adjusted for different speeds and types). These boundaries act as limits; when the price moves outside of these envelopes, it suggests a significant deviation from the norm.
The indicator evaluates market conditions using the following hierarchy:
1. Strong Signal Identification (Primary Action) The script looks for instances where the current price (specifically the midpoint between the high and low of a candle) breaks significantly beyond the established upper or lower envelopes.
- Strong Selling: If the price falls below the lower boundary, the tool identifies this as a potential entry point or a signal of downward pressure.
- Strong Buying: If the price rises above the upper boundary, the tool identifies this as a signal of upward pressure.
2. Weak Signal Identification (Secondary Action) In scenarios where the price is currently trading within the boundaries (meaning no "strong" signal has been triggered), the indicator switches to a secondary logic. It compares the current height of the upper envelope to its previous position.
- Weak Selling: If the upper boundary is sloping downwards, it suggests that even though there isn't a major breakout, the overall trend is losing strength.
- Weak Buying: If the upper boundary is sloping upwards, it suggests a persistent, albeit less aggressive, upward momentum.
Summary of Visual Behavior
The indicator processes every historical candle on the chart to determine these states. Instead of just showing a static line, it populates four different data sets that allow a user to see at a glance whether the market is in a state of high-intensity movement (Strong) or gradual trend progression (Weak). This dual-layer logic allows traders to differentiate between "overstretched" price action and steady, sustainable trends.
//+------------------------------------------------------------------+
//| Áîëüøàÿ Êîëëåêöèÿ Ñåìàôîðîâ.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 double Deviation=0.6;
extern int Mode=MODE_SMA;//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 = "Envelopes("+MA+","+DoubleToStr(Deviation, 3)+")";
IndicatorShortName(Name);
return(0);
}
int deinit() { return(0); }
int start()
{
double envH, envL, m, envH0;
//----
for (int i = 0; i <= Bars; i++)
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=0;
envH=iEnvelopes(NULL, Minutes, MA, Mode, 0, Price, Deviation, MODE_UPPER, i);
envL=iEnvelopes(NULL, Minutes, MA, Mode, 0, Price, Deviation, MODE_LOWER, i);
envH0=iEnvelopes(NULL, Minutes, MA, Mode, 0, Price, Deviation, MODE_UPPER, i+1);
m = (Low[i]+High[i])/2;
if (envH<m){ ExtMapBuffer1[i] = 1; }//ïðîäàåì
if (envL>m){ ExtMapBuffer2[i] = 1; }//ïîêóïàåì
if (ExtMapBuffer1[i]==0 && ExtMapBuffer2[i] == 0)
{
if (envH<=envH0) ExtMapBuffer3[i]=1; // ïðîäàåì ñëàáî
if (envH>=envH0) ExtMapBuffer4[i]=1; // ïîêóïàåì ñëàáî
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments