Trend Manager
Download scriptThis tool, known as the Trend Manager, is designed to help traders visualize market momentum and identify potential trend shifts by analyzing the relationship between two different moving averages. Instead of just looking at price action alone, it creates a visual "buffer" or histogram on your chart to highlight significant market movements.
How the Logic Works
The script operates based on three core components:
1. The Movement Analysis (Moving Averages) The tool calculates two separate averages of the market's price history:
- A Fast Average, which reacts more quickly to recent price changes.
- A Slow Average, which represents the broader, long-term trend.
By comparing these two averages, the script determines the "gap" or distance between the current short-term momentum and the long-term direction.
2. The Divergence Threshold Not every small movement is considered significant. The tool uses a specific limit (a "Divergence Limit") to filter out market noise. It only reacts when the difference between the fast and slow averages exceeds this pre-defined boundary. This ensures that the visual signals appear only when there is substantial momentum moving in a specific direction.
3. Visualizing the Trend Once the movement exceeds the required limit, the script draws horizontal bars on your chart:
- Upward Momentum: When the fast average moves significantly above the slow average, the tool identifies an upward trend and marks it based on the high prices of those candles.
- Downward Momentum: When the fast average drops significantly below the slow average, the tool identifies a downward trend and marks it based on the low prices of those candles.
Summary for the User
Essentially, this script acts as a visual filter. It ignores minor price fluctuations and only "flags" the chart when the market shows strong, sustained momentum. By looking at these bars, you can more clearly identify whether the current trend is moving aggressively in one direction or if the market is currently in a state of equilibrium.
//+------------------------------------------------------------------+
//| Trend Manager.mq4 |
//| Copyright © 2006, Alejandro Galindo |
//| http://elCactus.com |
//+------------------------------------------------------------------+
// Based on indicator sold at traderstradingsystem.com
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
// Divergence controls
extern double DVLimit=0.0007;
extern int Fast_Period=23;
extern int Fast_Price=PRICE_OPEN;
extern int Slow_Period=84;
extern int Slow_Price=PRICE_OPEN;
extern int BarCount=1500;
//----
double SpanA_Buffer[];
double SpanB_Buffer[];
//----
int tickcount=0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
// histogram defined by top and bottom buffer
// pos or neg from top buffer determines color
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(0,SpanB_Buffer);
//SetIndexDrawBegin(0,TM_Period+TM_Shift-1);
//SetIndexLabel(0,"TM_Period+");
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(1,SpanA_Buffer);
//SetIndexDrawBegin(1,TM_Period+TM_Shift-1);
//SetIndexLabel(1,"TM_Period");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int pos;
int iFileHandle;
//----
double maF1, maF2, maS1, maS2;
double D;
//----
for(pos=BarCount; pos>=0; pos--)
{
// Create Divergence stage one
maF1=iMA(Symbol(),0,Fast_Period,0,MODE_SMA,Fast_Price,pos);
maS1=iMA(Symbol(),0,Slow_Period,0,MODE_SMA,Slow_Price,pos);
D=maF1-maS1;
//----
SpanA_Buffer[pos] =0;
SpanB_Buffer[pos] =0;
//----
if(D>=DVLimit )
{
SpanA_Buffer[pos] =High[pos];
SpanB_Buffer[pos] =High[pos]+(D-DVLimit);
}
if(D<=(DVLimit*(-1)) )
{
SpanA_Buffer[pos] =Low[pos];
SpanB_Buffer[pos] =Low[pos]+(D-DVLimit);
}
} //for
} //start
//+------------------------------------------------------------------+
Comments