TrendManagerOpen2_v1

Download script
TrendManagerOpen2_v1

The Trend Manager tool is designed to help traders visualize market momentum by identifying the current direction of price action through two different time horizons simultaneously. Instead of simply looking at where the price is right now, this script analyzes the "middle" price levels of recent history to determine if the market is moving up, down, or staying neutral.

How the Logic Works

The script operates by looking at two distinct sets of data points:

  1. Short-Term Analysis: It calculates a middle price over a small window of time.
  2. Longer-Term Analysis: It calculates a middle price over a larger window of time.

By comparing the current middle price to a previous point in history (the "shift"), the tool determines the direction of the trend for both periods.

Visual Indicators and Behavior

The tool represents this data on your chart using two different colored histograms. The behavior changes based on whether the short-term and long-term trends are moving in the same direction or opposite directions:

  • Trend Alignment (Moving Together): When both the short-term and long-term trends are moving in the same direction (e.g., both are trending up), the script displays two distinct levels. This shows you the specific movement of both the fast and slow trend components.
  • Trend Conflict (Opposing Directions): If the short-term trend is moving in one direction while the long-term trend is moving in the opposite direction, the tool merges the visual data into a single point. This indicates a state of transition or "noise" where the two timeframes are not in agreement.

Summary for Traders

Essentially, this script acts as a filter. It helps you see when the fast price action is backed by the larger trend (alignment) versus when the fast price action is merely a temporary fluctuation against the broader market direction (conflict). By watching these histograms, you can better identify periods of strong, consistent momentum compared to periods of market indecision.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
TrendManagerOpen2_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

// Trend Manager Open2.mq4
//
// Look & Feel based on indicator sold at traderstradingsystem.com
// No representation it is identical.
// This file is licensed under the terms of the GNU General Public License V2.
//
// (c) 2006 Matt Kennel (mbkennel@gmail.com) 

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue


extern int TM_Period_1 = 7;
extern int TM_Shift_1 = 2;
extern int TM_Period_2 = 13;
extern int TM_Shift_2 = 1; 

int Max_Period;
int Max_Shift; 

double SpanA_Buffer[];
double SpanB_Buffer[];
int a_begin;

int init()
{
   Max_Shift = MathMax(TM_Shift_1,TM_Shift_2);
   Max_Period = MathMax(TM_Period_1,TM_Period_2); 

   int b_begin = Max_Period+Max_Shift-1;  
   
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(0,SpanB_Buffer);
   SetIndexDrawBegin(0,b_begin);
   SetIndexLabel(0,"TM_Period+");
   
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(1,SpanA_Buffer);
   SetIndexDrawBegin(1,b_begin);
   SetIndexLabel(1,"TM_Period");

   return(0);
}

int start()
{
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double high,low,price;

   if(Bars<=Max_Period) return(0);
   if(counted_bars<1)
   {
      for(i=1;i<=Max_Period;i++) 
      {
         SpanA_Buffer[Bars-i]=0;
         SpanB_Buffer[Bars-i]=0;
      }
   }

   i=Bars-Max_Period;
   if(counted_bars>Max_Period) i=Bars-counted_bars-1;
   while(i>=0)
   {
      
      double M1, M1b;
      double M2, M2b;
      
      M1 = MiddlePrice(TM_Period_1,i);
      M1b = MiddlePrice(TM_Period_1,i+TM_Shift_1); 
      M2 = MiddlePrice(TM_Period_2,i);
      M2b = MiddlePrice(TM_Period_2,i+TM_Shift_2); 
     
      //
      double diff1 = (M1-M1b); // up or down on short term;
      double diff2 = (M2-M2b); // up or down on longer term.
      // each has three choices, hence six possibilities.
      
      
      
      if (diff1*diff2 <= 0.0) { // opposite signs
         SpanA_Buffer[i] = (M1+M2)*0.5; 
         SpanB_Buffer[i] = SpanA_Buffer[i]; 
      } else {
         SpanA_Buffer[i]  =  (M1+M2)*0.5; 
         SpanB_Buffer[i]  =  (M1b+M2b)*0.5;
      }
   //   Comment(SpanB_Buffer[i],"\n",SpanA_Buffer[i] );
      
      
      
      i--;
   }

   return(0);
}

double MiddlePrice(int nback, int shift) {
  double H = High[Highest(NULL,0,MODE_HIGH,nback,shift)];
  double L = Low[Lowest(NULL,0,MODE_LOW,nback,shift)];
  return( 0.5*(H+L)); 

} 

Comments