TD Sequential_v2

Author: James OBrien
TD Sequential_v2

This tool is designed to provide a visual representation of market momentum and trend strength by tracking consecutive price movements. It functions as an automated labeling system that identifies "sequences" on your trading chart, helping you visualize whether the current price action is gaining steam or beginning to exhaust.

How the Logic Works

The script monitors the closing prices of candles over a specific historical window. It looks for continuous patterns where the price consistently moves in one direction compared to its position several bars prior. Instead of just looking at the immediate last candle, it evaluates the trend across a five-bar interval to ensure the movement is meaningful.

Visual Indicators and Sequencing

The logic distinguishes between upward and downward movements, assigning different colors and positions to help you differentiate the market sentiment at a glance:

  • Downward Sequences (Bearish Momentum): When the price shows a consistent downward trend, the script counts the consecutive occurrences. These are displayed as numbers appearing below the candles.

    • Early Sequence: Small numbers appear in Red, indicating the start of a downward move.
    • Critical Threshold: When the sequence reaches "9," the number increases in size to alert you to significant momentum.
    • Extended Trend: If the downward move continues beyond 10 consecutive counts, the color shifts to Orange, signaling an established, long-term trend.
  • Upward Sequences (Bullish Momentum): When the price shows a consistent upward trend, the script performs a parallel count, displaying these numbers above the candles.

    • Early Sequence: Small numbers appear in Royal Blue, indicating the start of an upward move.
    • Critical Threshold: Similar to the bearish side, reaching "9" increases the font size to highlight high-momentum growth.
    • Extended Trend: If the upward move persists beyond 10 consecutive counts, the color shifts to Light Sky Blue, marking a sustained bullish trend.

Summary for the Trader

Essentially, this script removes the guesswork of manually counting price movements. By providing real-time numerical labels, it helps you identify:

  1. Trend Strength: How many bars the market has been moving in one direction.
  2. Momentum Shifts: When a sequence is growing (large numbers) or if it is starting to break.
  3. Market Exhaustion: By identifying when a trend becomes "extended" (the 10+ count), it helps you spot areas where the price might be overextended and potentially due for a correction.
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
TD Sequential_v2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//| 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