T3 Taotra_NK

Author:
T3 Taotra_NK

This script is a technical analysis tool designed for the MetaTrader platform to help traders visualize price trends. It utilizes an advanced mathematical smoothing technique known as the "T3" algorithm, which is favored for its ability to reduce market noise while maintaining a very responsive curve.

Core Functionality

The logic of this script centers on creating six distinct trend lines simultaneously. Unlike standard moving averages that might lag significantly behind price action, this tool uses a recursive calculation method. It blends the current closing price with historical data points in a way that emphasizes recent movements without creating the erratic "zig-zag" patterns often seen in simpler indicators.

Key Components of the Logic:

  • Multi-Layered Smoothing: The script processes six different time periods (defaulting to 3, 5, 8, 12, 21, and 34). Each period represents a different "look-back" window, allowing you to see both short-term momentum and long-term structural trends at a single glance.
  • The T3 Algorithm: The indicator employs a specific weight-based formula. It takes the price data and passes it through a multi-stage smoothing process. By applying different coefficients (weights), it ensures that the resulting lines are "faster" than standard moving averages but still smooth enough to provide clear signals.
  • Dynamic Buffer Management: To ensure accuracy, the script maintains "memory" of previous calculations. It tracks historical values so that as new price data arrives, the trend lines remain continuous and mathematically consistent with their past movements.
  • Visual Output: The logic translates these complex calculations into six different colored lines on your main chart. By comparing the interaction between these six lines—such as when they converge, cross, or spread apart—traders can identify potential shifts in market direction.

How it Works for the User

When you apply this script, it constantly scans the closing prices of the assets you are trading. It calculates the weighted average for all six periods and plots them on your screen. Because it uses the T3 method, the lines are designed to "hug" the price more closely than a standard moving average would, helping to identify the true direction of the market while filtering out insignificant price fluctuations.

Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
T3 Taotra_NK
//+------------------------------------------------------------------+
//|                                          Version  July 20, 2006  |
//|   Editing   Nikolay Kositsin  15.06.2006  farria@mail.redcom.ru  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                    T3 Taotra.mq4 |
//|                                T3 code: Copyright © 1998, Tilson |
//+------------------------------------------------------------------+
#property copyright ""
#property link "" 
//---- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
#property indicator_chart_window 
//---- êîëè÷åñòâî èíäèêàòîðíûõ áóôôåðîâ
#property indicator_buffers 6
//---- öâåòà èíäèêàòîðà
#property indicator_color1 Brown
#property indicator_color2 Red
#property indicator_color3 Purple
#property indicator_color4 Aqua
#property indicator_color5 Green
#property indicator_color6 Blue
//---- ÂÕÎÄÍÛÅ ÏÀÐÀÌÅÒÐÛ ÈÍÄÈÊÀÒÎÐÀ 
extern int MA_Period_1 = 3; // ïåðèîä èíäèêàòîðà 1
extern int MA_Period_2 = 5; // ïåðèîä èíäèêàòîðà 2
extern int MA_Period_3 = 8; // ïåðèîä èíäèêàòîðà 3
extern int MA_Period_4 = 12;// ïåðèîä èíäèêàòîðà 4
extern int MA_Period_5 = 21;// ïåðèîä èíäèêàòîðà 5
extern int MA_Period_6 = 34;// ïåðèîä èíäèêàòîðà 6
//----
extern int Shift1 = 0;  // cäâèã èíäèêàòîðà 1 âäîëü îñè âðåìåíè 
extern int Shift2 = 0;  // cäâèã èíäèêàòîðà 2 âäîëü îñè âðåìåíè
extern int Shift3 = 0;  // cäâèã èíäèêàòîðà 3 âäîëü îñè âðåìåíè
extern int Shift4 = 0;  // cäâèã èíäèêàòîðà 6 âäîëü îñè âðåìåíè
extern int Shift5 = 0;  // cäâèã èíäèêàòîðà 5 âäîëü îñè âðåìåíè
extern int Shift6 = 0;  // cäâèã èíäèêàòîðà 6 âäîëü îñè âðåìåíè
extern double b = 0.7;
//---- èíäèêàòîðíûå áóôôåðû
double Ind_Buffer1[];
double Ind_Buffer2[];
double Ind_Buffer3[];
double Ind_Buffer4[];
double Ind_Buffer5[];
double Ind_Buffer6[];
//----
double e1[6], e2[6], e3[6], e4[6], e5[6], e6[6];
double c1, c2, c3, c4, Price, Resalt[6];
double n[6], w1[6], w2[6], b2, b3;
int M[6];
//---- ââåäåíèå ïåðåìåííûõ äëÿ ñîõðàíåíèÿ ïåðåìåííûõ  e1,e2,e3,e4,e5,e6
int time2; 
double E1[6], E2[6], E3[6], E4[6], E5[6], E6[6];
//+------------------------------------------------------------------+
//| T3 Taotra initialization function                                |
//+------------------------------------------------------------------+
int init()
  {
 //---- îïðåäåëåíèå ñòèëÿ èñïîëíåíèÿ ãðàôèêà
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexStyle(4, DRAW_LINE);
   SetIndexStyle(5, DRAW_LINE);
//----
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
//---- èìÿ äëÿ îêîí äàííûõ è ëýéáà äëÿ ñóáúîêîí
   IndicatorShortName("T3 Taotra");
//---- óñòàíîâêà íîìåðà áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò îòðèñîâûâàòüñÿ èíäèêàòîð 
   SetIndexDrawBegin(0, 100);
   SetIndexDrawBegin(1, 100);
   SetIndexDrawBegin(2, 100);
   SetIndexDrawBegin(3, 100);
   SetIndexDrawBegin(4, 100);
   SetIndexDrawBegin(5, 100);
//---- 6 èíäèêàòîðíûõ áóôôåðîâ èñïîëüçîâàíû äëÿ ñ÷¸òà
   SetIndexBuffer(0, Ind_Buffer1);
   SetIndexBuffer(1, Ind_Buffer2);
   SetIndexBuffer(2, Ind_Buffer3);
   SetIndexBuffer(3, Ind_Buffer4);
   SetIndexBuffer(4, Ind_Buffer5);
   SetIndexBuffer(5, Ind_Buffer6);
//---- ãîðèçîíòàëüíûé ñäâèã èíäèêàòîðíûõ ëèíèé  
   SetIndexShift (0, Shift1); 
   SetIndexShift (1, Shift2); 
   SetIndexShift (2, Shift3); 
   SetIndexShift (3, Shift4); 
   SetIndexShift (4, Shift5); 
   SetIndexShift (5, Shift6); 
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
   SetIndexEmptyValue(0, 0);
   SetIndexEmptyValue(1, 0);
   SetIndexEmptyValue(2, 0);
   SetIndexEmptyValue(3, 0);
   SetIndexEmptyValue(4, 0);
   SetIndexEmptyValue(5, 0);
   SetIndexEmptyValue(6, 0);
//---- èíèöìàëèçàöèÿ ïåðåìåííûõ
   n[0] = MA_Period_1;
   n[1] = MA_Period_2;
   n[2] = MA_Period_3;
   n[3] = MA_Period_4;
   n[4] = MA_Period_5;
   n[5] = MA_Period_6;
//----
   b2 = b*b;
   b3 = b2*b;
   c1 = -b3;
   c2 = (3*(b2 + b3));
   c3 = -3*(2*b2 + b + b3);
   c4 =(1 + 3*b + b3 + 3*b2);
//----
   for(int iii = 0; iii < 6; iii++)
     {
       M[iii] = 4*n[iii];
       if(n[iii] < 1) 
       n[iii] = 1;
       n[iii] = 1 + 0.5*(n[iii] - 1);
       w1[iii] = 2 / (n[iii] + 1);
       w2[iii] = 1 - w1[iii];
     }
//---- çàâåðøåíèå èíèöèàëèçàöèè
   return(0);
  }
//+------------------------------------------------------------------+
//| T3 Taotra iteration function                                     |
//+------------------------------------------------------------------+
int start()
  {
//----+ Ââåäåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ
    int limit, nnn, bar, MaxBar, counted_bars = IndicatorCounted();
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
    if(counted_bars < 0)
        return(-1);
//---- ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí
    if(counted_bars > 0) 
        counted_bars--;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò 
//     ïðîèçåä¸í ïåðåñ÷¸ò âñåõ áàðîâ
    MaxBar = Bars - 1;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò 
//     ïðîèçåä¸í ïåðåñ÷¸ò òîëüêî íîâûõ áàðîâ
    limit = (Bars -1 - counted_bars);
//+--- äî îñíîâíîãî öèêëà ðàñ÷¸òà èíäèêàòîðà âîññòàíàâëèâàåì çíà÷åíèÿ 
//     ïåðåìåííûõ, êàêèìè îíè áûëè ïîñëå ðà÷¸òà íà âòîðîì áàðå
//+--- âîññòàíîâëåíèå çíà÷åíèé ïåðåìåííûõ
    int Tnew = Time[limit+1];
    if(limit < MaxBar)
        if(Tnew == time2)
            for(int xxx = 0; xxx < 6; xxx++)
               {
                e1[xxx] = E1[xxx]; 
                e2[xxx] = E2[xxx]; 
                e3[xxx] = E3[xxx]; 
                e4[xxx] = E4[xxx]; 
                e5[xxx] = E5[xxx]; 
                e6[xxx] = E6[xxx];  
              }
            else 
              {
                if(Tnew > time2)
                    Print("ERROR01");
                else 
                    Print("ERROR02");
                return(-1);
              }
//----
    for(bar = limit; bar >= 0; bar--)
      {
        //+--- Çàïîìèíàåì çíà÷åíèÿ ïåðåìåííûõ, êàêèìè îíè áûëè ïîñëå âòîðîãî áàðà
        //+--- Ñîõðàíåíèå çíà÷åíèé ïåðåìåííûõ +=============+ 
        if(bar == 1)
            if(((limit == 1) && (time2 != Time[2])) || (limit > 1))
              {
                time2 = Time[2]; 
                for(int yyy = 0; yyy < 6; yyy++)
                  {
                    E1[yyy] = e1[yyy]; 
                    E2[yyy] = e2[yyy]; 
                    E3[yyy] = e3[yyy]; 
                    E4[yyy] = e4[yyy]; 
                    E5[yyy] = e5[yyy]; 
                    E6[yyy] = e6[yyy];  
                  }
              }
        //+---+============================================+
        for(nnn = 0; nnn < 6; nnn++)
          {
            Price = Close[bar];
            e1[nnn] = w1[nnn]*Price   + w2[nnn]*e1[nnn];
            e2[nnn] = w1[nnn]*e1[nnn] + w2[nnn]*e2[nnn];
            e3[nnn] = w1[nnn]*e2[nnn] + w2[nnn]*e3[nnn];
            e4[nnn] = w1[nnn]*e3[nnn] + w2[nnn]*e4[nnn];
            e5[nnn] = w1[nnn]*e4[nnn] + w2[nnn]*e5[nnn];
            e6[nnn] = w1[nnn]*e5[nnn] + w2[nnn]*e6[nnn];
            //----
            if(bar <= Bars - M[nnn])
                Resalt[nnn] = c1*e6[nnn] + c2*e5[nnn] + c3*e4[nnn] + c4*e3[nnn];
            //---- èíèöèàëèçàöèÿ íóëÿ
            else 
                Resalt[nnn] = 0;
          }
        Ind_Buffer1[bar] = Resalt[0];
        Ind_Buffer2[bar] = Resalt[1];
        Ind_Buffer3[bar] = Resalt[2];
        Ind_Buffer4[bar] = Resalt[3];
        Ind_Buffer5[bar] = Resalt[4];
        Ind_Buffer6[bar] = Resalt[5];       
      }
//----
    return(0);
  }
//+------------------------------------------------------------------+

Comments