[i]2MA_DivergenceTrader_Ron_MT4_v04_v1

Download script
[i]2MA_DivergenceTrader_Ron_MT4_v04_v1

This script, titled "Trend Manager," is designed to provide visual clarity regarding market momentum and potential trend shifts by identifying specific price movements relative to moving averages. Instead of just showing standard lines, it utilizes a combination of histograms and smoothed averages to help traders interpret market direction more intuitively.

Core Logic Overview

The tool operates by calculating two different types of Moving Averages: a "Fast" average and a "Slow" average. By comparing these two, the script determines the distance between current market speed and historical price trends.

The primary logic functions as follows:

  • Trend Identification: The script constantly calculates the difference between the Fast and Slow moving averages. This difference represents the "momentum" of the market.
  • Visualizing Divergence: When the momentum exceeds a specific threshold (defined by the user as a limit), the script generates visual signals on the chart.
    • Upward Momentum: If the gap between the averages becomes significantly positive, the tool creates upward-facing histogram elements.
    • Downward Momentum: If the gap becomes significantly negative, it creates downward-facing histogram elements.
  • Dynamic Scaling: The height and position of these visual indicators are tied directly to the magnitude of the difference between the two averages. This means that as the trend strengthens, the visual representation grows more pronounced, allowing you to see at a glance how powerful the current movement is.

Key Features for Traders

  • Customizable Sensitivity: Users can adjust the "Limit" to decide how aggressive the signals should be. A higher limit means only very strong trends will trigger a visual response, while a lower limit captures smaller fluctuations.
  • Flexible Timeframes: The logic allows for different settings for both the fast and slow averages, meaning it can be tuned to detect short-term "bursts" or long-term "swells" in price action.
  • Optional Visual Aids: While the primary function is the histogram-based trend detection, the script also includes the option to display the underlying Moving Averages directly on the chart for those who prefer to see the raw data behind the signals.

In summary, this tool acts as a visual filter. It takes complex moving average calculations and translates them into clear, height-adjusted histograms that highlight where the market is showing significant momentum relative to its recent history.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
[i]2MA_DivergenceTrader_Ron_MT4_v04_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

// Trend Manager.mq4
// Based on indicator sold at traderstradingsystem.com

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 LawnGreen

// Divergence controls
extern double DVLimit=0.0007;
extern bool   ShowMAs=false;
extern int    Fast_TimeFrame=0;
extern int    Fast_Period=23;
extern int    Fast_Price = PRICE_OPEN;
extern int    Fast_Mode = MODE_SMA;
extern int    Fast_Shift=0;
extern int    Slow_TimeFrame=0;
extern int    Slow_Period=84;
extern int    Slow_Price = PRICE_OPEN;
extern int    Slow_Mode = MODE_SMA;
extern int    Slow_Shift=0;
extern int    BarCount=1500;

double SpanA_Buffer[];
double SpanB_Buffer[];
double ma1[];
double ma2[];

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");

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ma1);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ma2);

}

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(),Fast_TimeFrame,Fast_Period,Fast_Shift,Fast_Mode,Fast_Price,pos);
      maS1=iMA(Symbol(),Slow_TimeFrame,Slow_Period,Slow_Shift,Slow_Mode,Slow_Price,pos);
      D=maF1-maS1;

      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);
        }

      if(ShowMAs)
        {
          ma1[pos]=maS1;
          ma2[pos]=maF1;
        }

     } //for

  } //start


Comments