TrendManager

Download script
TrendManager

The Trend Manager is a visual analytical tool designed to help traders identify and track market momentum by smoothing out price fluctuations. Its primary goal is to filter out "market noise"—the minor, erratic ups and downs of price action—to reveal the underlying direction of the trend.

Core Logic and Methodology

The script operates by analyzing specific windows of historical price data to calculate significant price levels. Here is how the logic unfolds:

1. Data Aggregation (The Look-back Period) The tool examines a set number of recent price candles (defined by the user as the "Period"). Instead of looking at just the most recent price, it scans this entire window to identify two critical points:

  • The highest price reached during that period.
  • The lowest price reached during that period.

2. Midpoint Calculation Once the highest and lowest points for the period are identified, the tool calculates the mathematical average (the midpoint) between them. This represents a balanced "fair value" for that specific timeframe.

3. Dynamic Mapping (Dual Buffers) The script generates two distinct visual paths on your chart to help differentiate between current movement and preceding trends:

  • Primary Path: This maps the calculated midpoints across the chart, providing a smoothed representation of where the price "center" has been moving.
  • Shifted Path: The tool also creates a secondary path that is slightly offset in time (the "Shift"). By comparing the current midpoint to a midpoint from a few bars back, the script creates a visual distinction between immediate price action and established trend history.

Visual Output

The results are displayed as histograms on the chart. By observing the relationship between these two paths, traders can visually assess whether the market is gaining strength, losing momentum, or entering a period of consolidation. When the calculated midpoints shift significantly upward or downward over time, it signals a change in the prevailing market trend.

7 Views
0 Downloads
0 Favorites
TrendManager
// 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