Trend Trigger Modified

Author: Copyright � 2005, MetaQuotes Software Corp.
Trend Trigger Modified

This tool is designed to help traders visualize and identify market trends by analyzing the relationship between recent price action and historical price extremes. It works by calculating a momentum-based score that represents the balance of "buying pressure" versus "selling pressure."

Core Logic and Methodology

The script functions through three primary stages of calculation:

1. Price Extremes Analysis The tool looks at specific windows of time on the chart to identify key price points. It captures the highest highs and lowest lows over two distinct periods:

  • A "Recent" window (the most immediate price action).
  • An "Older" window (a slightly previous section of history).

2. Pressure Calculation By comparing these extremes, the tool determines the strength of the current move:

  • Buy Power: Calculated by measuring the distance between the recent high and the older low. This represents the total upward reach of the market relative to its previous base.
  • Sell Power: Calculated by measuring the distance between the older high and the recent low. This represents the downward reach of the market relative to its previous peak.

The tool then combines these figures into a single percentage value. This value tells you whether the current market movement is favoring the bulls (buyers) or the bears (sellers).

3. Smoothing and Filtering To prevent the data from being too erratic or "noisy," the script applies two layers of refinement:

  • Weighting: It uses a mathematical weighting system to ensure that the most recent data carries significant importance while still considering the context of the broader movement.
  • Smoothing: The raw momentum score is processed through a series of calculations designed to smooth out sudden spikes, providing a cleaner line that is easier for a human trader to interpret visually.

Visual Representation

The indicator provides a clear visual guide in a separate window:

  • The Primary Line: This shows the smoothed trend value. When the line moves upward, it indicates increasing buying momentum; when it moves downward, it suggests selling dominance.
  • The Threshold Signal: The script includes a secondary logic point that categorizes the environment. If the trend value is positive, it marks a clear bullish leaning; if negative, it marks a bearish leaning. This helps traders quickly identify which direction the market "weight" is currently shifting.
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Trend Trigger Modified
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                       Trend Trigger Modified.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 SkyBlue
#property indicator_color2 LightSeaGreen
//---- input parameters
extern int       TTFbars=15;
extern int       t3_period=5;
extern double    b=0.7;
//---- buffers
double Buf1[];
double Buf2[];

// Variable Specific:
string IndicatorName = "py.TTF";
string Version = "S01";
double HighestHighRecent,
       HighestHighOlder,
       LowestLowRecent,
       LowestLowOlder,
       BuyPower,
       SellPower,TTF;
double t3,e1,e2,e3,e4,e5,e6,c1,c2,c3,c4,r,w1,w2,b2,b3;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buf1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Buf2);
   
   b2 = b * b;
   b3 = b2 * b;
   c1 = (-b3);
   c2 = (3 * (b2 + b3));
   c3 = (-3) * (2 * b2 + b + b3);
   c4 = (1 + 3 * b + b3 + 3 * b2);

   r = t3_period;

   if (r < 1) r = 1;
   r = 1 + 0.5 * (r - 1);
   w1 = 2 / (r + 1);
   w2 = 1 - w1 ;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- 
   int limit = Bars-counted_bars-1;
   for(int i=limit; i>0; i--)
   {	
     HighestHighRecent = High[Highest(NULL,0,MODE_HIGH,TTFbars,i)];
	  HighestHighOlder = High[Highest(NULL,0,MODE_HIGH,TTFbars,i + TTFbars)];
	  LowestLowRecent = Low [Lowest(NULL,0,MODE_LOW,TTFbars,i)];
	  LowestLowOlder = Low [Lowest(NULL,0,MODE_LOW,TTFbars,i+TTFbars)];
	  BuyPower = HighestHighRecent - LowestLowOlder;
	  SellPower = HighestHighOlder - LowestLowRecent;
	  TTF = (BuyPower - SellPower) / (0.5 * (BuyPower + SellPower)) * 100;

	  e1 = w1 * TTF + w2 * e1;
	  e2 = w1 * e1 + w2 * e2;
	  e3 = w1 * e2 + w2 * e3;
	  e4 = w1 * e3 + w2 * e4;
	  e5 = w1 * e4 + w2 * e5;
	  e6 = w1 * e5 + w2 * e6;

	  TTF = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3;
     Buf1[i] = TTF;
     if (TTF >= 0) Buf2[i] = 50;
     else Buf2[i] = -50;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments