TD_Sequential

Author: James OBrien
TD_Sequential

This tool is designed to provide visual tracking of price momentum by identifying and labeling consecutive trends directly on your trading chart. It functions by monitoring the relationship between current price points and historical data to determine if a market move is strengthening or potentially reaching an exhaustion point.

Core Functionality

The script automatically scans historical price action to identify "sequences." Instead of just showing where the price is, it counts how many times the price has moved in a specific direction consecutively. These counts are then displayed as numerical labels on the chart:

  • Downward Momentum: When the market is moving down consistently, the tool tracks the sequence. It places numerical markers below the candles to show the progression of the decline.
  • Upward Momentum: Conversely, when the market is moving up, it tracks the upward progression and places corresponding numerical labels above the candles.

Visual Indicators and Logic

The logic uses a specific counting system to help traders identify potential trend fatigue:

  • Standard Sequences (1-8): These represent the early and mid-stages of a trend. They are displayed in standard colors (Red for down, Royal Blue for up) to indicate active movement.
  • Critical Thresholds (9): When a sequence reaches the number 9, the tool increases the text size significantly. This serves as a visual alert that the trend has been sustained for a long duration and may be approaching a turning point.
  • Extended Trends (10+): If a trend continues beyond 10 consecutive movements, the color of the labels shifts (to Orange for down and LightSkyBlue for up). This helps distinguish between a standard trend and an extended "overextended" market move.

Practical Application

By providing these real-time counts, the tool allows you to see at a glance how far a trend has traveled. Rather than guessing if a price movement is "too high" or "too low," you can use these numbers to visually gauge whether a market move is becoming overstretched, potentially signaling a need for caution or an upcoming reversal.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
TD_Sequential
//+------------------------------------------------------------------+
//|                                                TD_Sequential.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "James OBrien"
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 LimeGreen
//#property indicator_color2 Red
//---- input parameters
//int shift=0;
int i;
int num=0;
int num1=0;
string textVar;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];

//double b4plusdi,b4minusdi,nowplusdi,nowminusdi;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators

SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,159);
SetIndexBuffer(0, ExtMapBuffer1);
/*
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,234);
SetIndexBuffer(1, ExtMapBuffer2);
*/
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
int limit;
limit=1500;
for(int i=limit; i>=0; i--)
{
	ObjectDelete(""+i);
}	

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);

//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=1500-counted_bars;
//---- macd counted in the 1-st buffer



for(int i=limit; i>=0; i--)
{
if(Close[i+1]<Close[i+5])num = num + 1; 
else num = 0;	
	if (num > 0 && num < 10) {
		textVar = num;
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-5*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num,0), 10, "Arial", Red);
		}
		if (num == 9) {
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-5*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num,0), 16, "Arial", Red);
      }				
		else if((Close[i+1]<Close[i+5])&& num>=10)
		{
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-5*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num,0), 10, "Arial", Orange);				
		}
	

if(Close[i+1]>Close[i+5]) num1 = num1 + 1; 
else num1 = 0;

	if (num1 > 0 && num1 < 10) 
	   {
		textVar = num1;
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+10*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num1,0), 10, "Arial", RoyalBlue);
		}
		if (num1 == 9) {
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+10*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num1,0), 16, "Arial", RoyalBlue);
      }				
		else if((Close[i+1]>Close[i+5])&& num1>=10)
		{
		ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+10*Point );
      ObjectSetText(""+i, ""+DoubleToStr(num1,0), 10, "Arial", LightSkyBlue);
					
		}
  
  	
}

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




Comments