thz42avc_5fbpbzqw9re2_dso3765ry_7wfccwand
Download scriptThis technical indicator is designed to analyze market momentum and trend strength by identifying significant price boundaries. It serves as a visual tool to help traders determine whether the current market direction is leaning toward a "Buy" or "Sell" sentiment based on historical price behavior and moving averages.
Core Logic and Methodology
The script operates by calculating several different simple moving averages (SMA) over a specific user-defined time period. By comparing these multiple averages simultaneously, the tool establishes a dynamic range of market activity:
- Dynamic Boundary Detection: The script looks at a cluster of moving averages to identify the highest and lowest "levels" reached within that timeframe. These levels act as the ceiling (Upper Bound) and the floor (Lower Bound) for the current trend.
- Trend Directionality: The logic evaluates the relationship between the current price action (the Highs and Lows of the current candle) and these calculated boundaries:
- If the price breaks above the upper boundary, the tool identifies a positive momentum.
- If the price drops below the lower boundary, it identifies a negative momentum.
- If the price fluctuates between both boundaries simultaneously, the trend is considered neutral or undecided.
Visual Output and User Feedback
The indicator provides three distinct visual elements on the trading chart to help with navigation:
- Trend Boundaries: Two primary lines are plotted on the chart. One represents the "upper limit" and the other represents the "lower limit." These change dynamically as new price data enters the system, showing you where the current trend is reacting.
- Median Line: A third, dotted line is displayed to show the exact midpoint between the upper and lower boundaries. This helps traders identify the balance point of the current market movement.
- Real-Time Alerts: Beyond the visual lines on the chart, the script provides immediate text feedback in the corner of the screen. It automatically displays a "BUY" or "SELL" signal along with the specific price level of the trend boundary, allowing for quick identification of trade entries.
Summary of Functionality
Instead of relying on a single moving average which can often be lagging, this script looks at a "bundle" of averages to define a zone of influence. It then watches how the price interacts with that zone to determine if the trend is breaking out in a bullish or bearish direction, providing the user with clear visual boundaries and text-based signals for more informed decision-making.
//+------------------------------------------------------------------+
//| |
//| Copyright © 2000-2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// Ñèëà òðåíäà (ñòîï ëîññ).mq4
// Îïèñàíèå http://www.kroufr.ru/content/view/697/124/
#property copyright "mandorr@gmail.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Silver
//----
extern int PeriodStep=10; // Øàã ïåðèîäà ñêîëüçÿùèõ
//----
double buffer0[];
double buffer1[];
double buffer2[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,buffer0);
SetIndexLabel(0,"Âåðõíÿÿ ãðàíèöà");
SetIndexDrawBegin(0,0);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,buffer1);
SetIndexLabel(1,"Íèæíÿÿ ãðàíèöà");
SetIndexDrawBegin(1,0);
SetIndexStyle(2,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(2,buffer2);
SetIndexLabel(2,"Ìåäèàíà");
SetIndexDrawBegin(2,0);
IndicatorShortName("Ñèëà òðåíäà (ñòîï ëîññ) ("+(string)PeriodStep+")");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void deinit()
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void start()
{
int dir=0;
int step=1; if (PeriodStep>1) step=PeriodStep;
double h, l, x1, x2, x3, x4, x5, x6;
int counted_bars=IndicatorCounted();
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=6*step+1;
for(int i=limit; i>=0; i--)
{
x1=iMA(NULL,0,1*step,0,MODE_SMA,PRICE_CLOSE,i);
x2=iMA(NULL,0,2*step,0,MODE_SMA,PRICE_CLOSE,i);
x3=iMA(NULL,0,3*step,0,MODE_SMA,PRICE_CLOSE,i);
x4=iMA(NULL,0,4*step,0,MODE_SMA,PRICE_CLOSE,i);
x5=iMA(NULL,0,5*step,0,MODE_SMA,PRICE_CLOSE,i);
x6=iMA(NULL,0,6*step,0,MODE_SMA,PRICE_CLOSE,i);
h=x1;
l=x1;
if (h<x2) h=x2;
if (h<x3) h=x3;
if (h<x4) h=x4;
if (h<x5) h=x5;
if (h<x6) h=x6;
if (l>x2) l=x2;
if (l>x3) l=x3;
if (l>x4) l=x4;
if (l>x5) l=x5;
if (l>x6) l=x6;
if (High[i]>h) dir= 1;
if (Low [i]<l) dir=-1;
if (High[i]>h && Low[i]<l) dir=0;
buffer0[i]=EMPTY_VALUE;
buffer1[i]=EMPTY_VALUE;
if (dir<0) buffer0[i]=h;
if (dir>0) buffer1[i]=l;
buffer2[i]=(h+l)/2;
}
if (buffer0[0]!=EMPTY_VALUE) Comment("SELL; ñòîï ëîññ: "+DoubleToStr(buffer0[0],Digits));
if (buffer1[0]!=EMPTY_VALUE) Comment("BUY; ñòîï ëîññ: "+DoubleToStr(buffer1[0],Digits));
}
//+------------------------------------------------------------------+
Comments