TrendManager_v1
Download scriptThis tool, known as the Trend Manager, is designed to provide visual clarity on a trading chart by identifying and smoothing out price action trends. Rather than showing every volatile movement of the market, it focuses on distilling price data into a more manageable format to help traders recognize underlying momentum.
Core Logic and Methodology
The script functions by analyzing specific windows of historical price data to determine key "high" and "low" points. Instead of looking at just the most recent candle, it looks back over a user-defined period to find the extremes of the market's range during that timeframe.
1. Identifying Price Extremes The tool scans the market to find the highest peak and the lowest valley within its designated lookback window. By identifying these two points, the script establishes the "boundaries" of the current price movement.
2. Calculating the Midpoint (Span A) Once the highest high and the lowest low are identified for that period, the logic calculates the mathematical average—the exact midpoint between those two extremes. This result is plotted as a primary histogram on your chart. This represents the "center of gravity" for the price during that specific timeframe.
3. Creating the Lagged Buffer (Span B) To provide a smoother visual representation and to better highlight trend changes, the tool calculates a second value. It takes the midpoint from a slightly previous point in time (based on a user-defined shift) and plots it alongside the current midpoint.
Visual Interpretation
By plotting these two different midpoints as histograms, the tool creates a visual "envelope" or "spread."
- Trend Identification: When the two values move in synchronization with a clear direction, it indicates a sustained trend.
- Momentum Tracking: The gap or convergence between the primary midpoint and its lagged counterpart helps traders see how quickly the price is reacting to new data.
In essence, this script filters out "market noise" by ignoring minor fluctuations and instead highlighting the core balance point of price action over time.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
// Trend Manager.mq4
// Based on indicator sold at traderstradingsystem.com
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
extern int TM_Period = 7;
extern int TM_Shift = 2;
double SpanA_Buffer[];
double SpanB_Buffer[];
int a_begin;
int init()
{
a_begin=TM_Shift;
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(0,SpanB_Buffer);
SetIndexDrawBegin(0,TM_Period+a_begin-1);
SetIndexLabel(0,"TM_Period+");
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(1,SpanA_Buffer);
SetIndexDrawBegin(1,TM_Period+a_begin-1);
SetIndexLabel(1,"TM_Period");
return(0);
}
int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double high,low,price;
if(Bars<=TM_Period) return(0);
if(counted_bars<1)
{
for(i=1;i<=TM_Period;i++)
{
SpanA_Buffer[Bars-i]=0;
SpanB_Buffer[Bars-i]=0;
}
}
i=Bars-TM_Period;
if(counted_bars>TM_Period) i=Bars-counted_bars-1;
while(i>=0)
{
high=High[i]; low=Low[i]; k=i-1+TM_Period;
while(k>=i)
{
price=High[k];
if(high<price) high=price;
price=Low[k];
if(low>price) low=price;
k--;
}
SpanA_Buffer[i] = (high+low)/2.0;
SpanB_Buffer[i] = SpanA_Buffer[i+TM_Shift];
i--;
}
return(0);
}
Comments