TD Sequential

Author: James OBrien
TD Sequential

This script is designed to work as a visual aid on your trading chart, specifically focusing on tracking momentum and price trends by identifying sequences of consecutive movements. Instead of using standard lines or bars, it uses numerical labels to "count" how many times the market has moved in a specific direction over a set period.

Core Logic Overview

The script monitors the relationship between current price closes and past price closes (specifically looking at the price from 5 candles ago). It operates by identifying two distinct types of trends:

1. Downward Momentum Tracking The tool looks for instances where the price is consistently decreasing.

  • The Count: Every time the previous candle's closing price is lower than the price from five candles prior, the script adds to a counter. If the condition fails, the count resets to zero.
  • Visual Cues: It places numbers below the price candles to show the strength of this downward streak.
    • Small numbers (1–8) appear in Red.
    • When the count reaches 9, the number increases in size to highlight a significant trend.
    • If the downward trend persists beyond 10 counts, the text changes to Orange, signaling a prolonged bearish move.

2. Upward Momentum Tracking Simultaneously, the script performs the same logic for upward movements.

  • The Count: It tracks instances where the price is consistently increasing relative to the five-candle lookback. If the trend breaks, the counter resets.
  • Visual Cues: It places numbers above the price candles to show the strength of this upward streak.
    • Small numbers (1–8) appear in Royal Blue.
    • When the count reaches 9, the number increases in size for emphasis.
    • If the upward trend persists beyond 10 counts, the text changes to Light Sky Blue, indicating a sustained bullish move.

Summary for Traders

Essentially, this script acts as a "streak counter." It helps you visually identify how long a price movement has been sustained in one direction without resetting. By glancing at the chart, you can see whether a trend is just beginning (small numbers), becoming significant (enlarged numbers), or becoming an extended move (color-changed labels).

Miscellaneous
Implements a curve of type %1
18 Views
0 Downloads
0 Favorites
TD Sequential
//+------------------------------------------------------------------+
//| FirstIndicator.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