TSequential
Download scriptThis technical script is designed to automate the visual analysis of the TD Sequential trading strategy on a price chart. It functions as an automated charting tool that identifies specific price patterns, momentum shifts, and potential trend reversals by tracking historical price movements.
Here is a breakdown of how the logic operates:
Pattern Recognition (The Setup)
The script constantly monitors the relationship between current price candles and those from several bars prior. It looks for specific "sequences" of movement:
- Bearish Sequence: It counts consecutive price drops. When it identifies a sequence of 9 such movements, it marks the chart with a numeric label to indicate a potential downward trend strength.
- Bullish Sequence: Conversely, it tracks consecutive price rises. When 9 of these occur, it labels the chart to highlight upward momentum.
Confirmation Signals (The X Marks)
Once a sequence is identified, the script doesn't immediately signal a trade. Instead, it waits for a specific "confirmation" move:
- Bearish Confirmation: If a bearish sequence exists and the price reacts by falling below a certain historical low point, the script places a green "X" on the chart.
- Bullish Confirmation: If a bullish sequence exists and the price reacts by breaking above a previous high point, it places a yellow "X". These marks serve as visual alerts that the initial momentum has been validated by price action.
Momentum and Reversal Signals (The Symbols)
The script includes an advanced layer of logic to filter out "noise" and identify high-probability reversal points:
- Momentum Counting: After a confirmation mark appears, the script monitors how many times the price continues to move in that direction relative to previous highs/lows.
- Reversal Alerts: If the price fails to maintain this momentum consistently (crossing specific count thresholds), the script generates specific symbols:
- A "+" symbol appears when a trend shows signs of exhaustion or a potential turn.
- "V" and "^" symbols are plotted as final visual cues to highlight significant structural shifts in the market, providing a clearer picture of where a trend might be ending and a new one beginning.
Summary for the User
Essentially, this tool acts as an automated "scout." It filters through thousands of price candles to find complex patterns that would be difficult to track manually. By identifying the Sequence (strength), the Confirmation (validation), and the Reversal (potential entry/exit), it provides a layered visual map of market sentiment directly on your trading screen.
//+--------------------------------------------------------------------------+
//| TD Sequential.mq4 9-óñòàíîâêà |
//| Õ-ïåðåñå÷åíèå |
//| +-îòñ÷åò |
//| V èëè^- Ñèãíàë íà âõîä |
//| 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,a1=true,a2=false,setup1=false,setup=false,per=false,cc=0,per1=false;
int skok1,skok,cc1=0;
string textVar;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];
//double b4plusdi,b4minusdi,nowplusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,222);
SetIndexBuffer(1, 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);
ObjectDelete("11"+i);
ObjectDelete("22"+i);
ObjectDelete("21"+i);
ObjectDelete("12"+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])&& a1==true) {num = num + 1; a2=true;}
else {num = 0;}
if (num == 9) {
ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-10*Point );
ObjectSetText(""+i, ""+DoubleToStr(num,0), 16, "Arial", RoyalBlue);
setup=true;
a1=false;
per=false;
skok1=false;
cc1=0;
}
if(Close[i+1]>Close[i+5]&& a2==true) {num1 = num1 + 1; a1=true;}
else {num1 = 0; }
if (num1 == 9) {
ObjectCreate(""+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+50*Point );
ObjectSetText(""+i, ""+DoubleToStr(num1,0), 16, "Arial", Red);
setup1=true;
a2=false;
per1=false;
skok=false;
cc=0;
}
//Ïåðåñå÷åíèå
if (setup==true && High[i+1]>Low[i+4]){ObjectCreate("11"+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-10*Point );
ObjectSetText("11"+i, "X", 10, "Arial", Green);
per1=true; cc=0; setup=false;}
if (setup1==true && Low[i+1]<High[i+4]){ObjectCreate("11"+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+30*Point );
ObjectSetText("11"+i, "X", 10, "Arial", Yellow);
per=true; cc=0; setup1=false;}
//Îòñ÷åò
if (per==true && Close[i+1]>High[i+3]) {cc=cc+1;
if (cc>12) {cc=0; per=false; skok=true;
ObjectCreate("22"+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+100*Point );
ObjectSetText("22"+i, "+", 10, "Arial", Yellow); }}
if (per1==true && Close[i+1]<Low[i+3]) {cc1=cc1+1;
if (cc1>12) {cc1=0; per1=false; skok1=true;
ObjectCreate("22"+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-10*Point );
ObjectSetText("22"+i, "+", 10, "Arial", Green); }}
//Âõîä
if (skok==true && Close[i+1]<Low[i+3]) {skok=false;
ObjectCreate("12"+i, OBJ_TEXT, 0, Time[i+1],High[i+1]+100*Point );
ObjectSetText("12"+i, "V", 10, "Arial", Red);
}
if (skok1==true && Close[i+1]>High[i+3]) {skok1=false;
ObjectCreate("21"+i, OBJ_TEXT, 0, Time[i+1],Low[i+1]-10*Point );
ObjectSetText("21"+i, "^", 12, "Arial", Blue);
}
}
//----
return(0);
}
Comments