Author: Copyright � 2005, adoleh2000
TTM

This script is a visual trading tool designed to help market participants identify price trends and potential momentum shifts by analyzing the relationship between current price action and historical volatility. It operates by calculating specific "zones" based on recent price movements and plotting them as dynamic markers on your chart.

Core Logic Overview

The indicator functions by establishing a mathematical boundary around the current price. To do this, it performs three primary steps for every candle on the chart:

1. Establishing Trend Averages The tool first looks back at a specific number of recent candles (defined by a user-set period) to calculate two moving averages: one based on the "High" prices and one based on the "Low" prices. By using these averages, the script identifies the overall range in which the market has been oscillating.

2. Defining the "Action Zones" Once it knows the high and low averages, the script divides that price range into three equal segments. It then creates two specific threshold lines:

  • A Lower Threshold: The boundary of the bottom third of the range.
  • An Upper Threshold: The boundary of the top third of the range.

3. Visualizing Price Momentum The script then compares the actual closing price of a candle against these two thresholds to determine which direction the "momentum" is leaning:

  • Bullish Momentum: If the price closes above the Upper Threshold, the script identifies this as strong upward pressure and highlights the price action accordingly.
  • Bearish Momentum: If the price closes below the Lower Threshold, it identifies strong downward pressure.
  • Neutral Zone: If the price remains trapped between the two thresholds, the script effectively ignores the data, as the price is considered to be in a period of consolidation or indecision.

How it helps the trader

Instead of showing every tiny fluctuation in the market, this logic filters out the "noise." It focuses exclusively on instances where the price breaks out of the middle third of its recent range. By visually representing these breakouts, the tool helps traders see clearly when a trend is gaining significant strength, making it easier to spot potential entry points or trend continuations at a glance.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
TTM
//+------------------------------------------------------------------+
//|                                                          TTM.mq4 |
//|                             Copyright © 2005, adoleh2000 and dwt5|
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//| Based on code offered at MT Yahoo group                          |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, adoleh2000"
#property link      "adoleh2000@yahoo.com"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 EMPTY
#property indicator_color4 EMPTY



//---- input parameters
extern int TTMperiod=6;
//---- buffers
double HighBuffer[];
double LowBuffer[];
double  Low_ma,
	     High_ma,
	     Low_third[],
	     High_third[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);

 
   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexBuffer(2,High_third);
   SetIndexBuffer(3,Low_third);


//---- name for DataWindow and indicator subwindow label
   short_name="TTM";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);

//----

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted(),i,shift;
   

//---- TODO: add your code here
if (counted_bars==0) counted_bars=TTMperiod+1;
i=(Bars-counted_bars);

for (shift=i; shift>=0;shift--)
{

Low_ma= iMA(NULL,0,TTMperiod,0,MODE_EMA,PRICE_LOW,shift);
High_ma = iMA(NULL,0,TTMperiod,0,MODE_EMA,PRICE_HIGH,shift);
Low_third[shift] = (High_ma- Low_ma) / 3 + Low_ma;
High_third[shift] = 2 * (High_ma- Low_ma) / 3 + Low_ma;

//Comment ("Low_third=",Low_third[shift],"; ","High_third=",High_third[shift]);

if (Close[shift] > High_third[shift]) 
   { 
      HighBuffer[shift]=High[shift];
      LowBuffer[shift]=Low[shift]; 
   }
   
   else

if (Close[shift] < Low_third[shift]) 
   { 
      LowBuffer[shift]=High[shift];
      HighBuffer[shift]=Low[shift];
    }


 //----
}
   return(0);
  }
//+------------------------------------------------------------------+

Comments