THV_T3_Trix_MTF_01

Author: Modified MTF Trix by Peter D.
THV_T3_Trix_MTF_01

This tool is designed to help traders visualize market trends by combining data from different timeframes into a single, easy-to-read chart. It focuses on the "Trix T3" indicator, which is primarily used to identify momentum and price direction.

Core Functionality

The primary purpose of this script is Multi-Timeframe (MTF) Analysis. Instead of forcing you to switch back and forth between different charts (like moving from a 15-minute chart to a 4-hour chart), this tool "pulls" the data from your chosen higher timeframe and displays it directly on your current active chart.

How It Works

The script operates using three main logical steps:

1. Data Retrieval The tool connects to an underlying primary indicator (the Trix T3). It looks at a specific timeframe that you choose in the settings (e.g., Hourly or Daily) and retrieves two distinct sets of information:

  • Main Signal: The primary momentum reading.
  • Signal Line: A secondary smoothing line used to confirm trends.

2. Dynamic Mapping Because different timeframes have different numbers of price bars, the script contains logic to synchronize the data. It ensures that the data points from the higher timeframe align correctly with the candles on your current chart, preventing "visual gaps" or misaligned information.

3. Visual Categorization (Color Coding) To make the information digestible at a glance, the script automatically categorizes the momentum into four distinct visual elements:

  • Fast Trend Tracking: It monitors the primary signal and colors it based on whether the momentum is moving up or down. This gives you an immediate sense of "fast" market direction.
  • Slow Trend Tracking: It monitors the secondary signal line, providing a "slow" trend view. This helps filter out minor price fluctuations to show you the broader, underlying move.

Summary for the User

By using this script, you can see the "big picture" of the market while remaining on your preferred trading timeframe. It provides a color-coded visual representation of momentum that allows you to quickly identify whether the higher-order trend is bullish (upward) or bearish (downward), helping you make more informed decisions without cluttering your workspace with multiple windows.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
THV_T3_Trix_MTF_01
/*
   Multple Time Frame Trix T3 Indicator for THV System
   This Multiple Time Frame TRIX T3 is for MTF purposes
   The original TRIX T3 remains untouched (orginal by Luis Damiani)
   
   Make sure the variable (strBaseCodeFileName) is set to the Original Trix filename...
*/
//mod

#property copyright "Modified MTF Trix by Peter D."

#property indicator_separate_window

#property indicator_buffers     4
#property indicator_color1      DodgerBlue    // Fast Trix Up
#property indicator_color2      OrangeRed    // Fast Trix Down
#property indicator_color3      Blue       // Slow Trix Up
#property indicator_color4      Magenta     // Slow Trix Down
#property indicator_width1      4
#property indicator_width2      4
#property indicator_width3      2
#property indicator_width4      2

//#property indicator_level1      0.0
//#property indicator_levelcolor  RoyalBlue
//#property indicator_levelstyle  2

//---- input parameters
extern string     TimeFrameInfo0 = "<<< Time Frame >>>";
extern int        TimeFrame = 0;
extern string     TimeFrameInfo1 = "";
extern string     TimeFrameInfo2 = "use: '0' for current timeframe";
extern string     TimeFrameInfo3 = "1->M1, 5->M5, 15->M15, 30->M30";
extern string     TimeFrameInfo4 = "60->H1, 240->H4, 1440->D1";
extern string     TimeFrameInfo5 = "10080->W1, 43200->MN1";

extern string     _ = "";
extern string     __ = "<<< Number of bars >>>";
extern int        TrixNumberOfBars=750;

extern string     ___ = "";
extern string     ____ = "<<< Trix settings >>>";
extern int        A_t3_period=15;//7//20;
extern int        B_t3_period_ac=5;//16//35;

int               is_A_open_price=0;
int               diferential=0;
double            hot=0.7;

string strBaseCodeFileName = "THV T3 Trix";
string   indicatorName;
//---- Arrays for Trix values
double dblMain[];
double dblSignal[];

// Indicator Buffers //
double dblTrixFastUp[];
double dblTrixFastDown[];
double dblTrixSlowUp[];
double dblTrixSlowDown[];

//+------------------------------------------------------------------+
//| init()
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

    IndicatorBuffers(6);


   SetIndexStyle(0,DRAW_HISTOGRAM);//LINE);
   SetIndexBuffer(0,dblTrixFastUp);
   SetIndexStyle(1,DRAW_HISTOGRAM);//LINE);
   SetIndexBuffer(1,dblTrixFastDown);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,dblTrixSlowUp);
   SetIndexLabel(2,EMPTY);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,dblTrixSlowDown);
   SetIndexLabel(3,EMPTY);


   SetIndexBuffer(4,dblMain);
   SetIndexBuffer(5,dblSignal);


//----
   string strTimeFrame = GetPeriodName(TimeFrame);
   indicatorName = "MTF Trix (" + strTimeFrame + ")";
   IndicatorShortName(indicatorName);
   TimeFrame=MathMax(TimeFrame,Period());



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

//+------------------------------------------------------------------+
//| start()
//+------------------------------------------------------------------+
int start()
  {
   datetime dtmTime[];
   int i;
   int j;
   int intMaxVal;
   int intTotBars = IndicatorCounted();

   intMaxVal = Bars-intTotBars+TimeFrame/Period();
   ArrayCopySeries(dtmTime, MODE_TIME, Symbol(), TimeFrame); 
// ArrayResize(dblMain, intMaxVal);ArrayResize(dblSignal, intMaxVal);
// j = 0;
   
   // Calculate TRIX Values //
   for(i=0,j=0; i<intMaxVal; i++)
   {
      if (Time[i] < dtmTime[j]) j++; 
      dblMain[i]=iCustom(NULL, TimeFrame, strBaseCodeFileName, TrixNumberOfBars, A_t3_period, B_t3_period_ac, 0, j);
      dblSignal[i]=iCustom(NULL, TimeFrame, strBaseCodeFileName, TrixNumberOfBars, A_t3_period, B_t3_period_ac, 1, j);
   }

   // Coloring //

  for(i=intMaxVal; i>=0; i--)
   {
      dblTrixFastUp[i] = EMPTY_VALUE; dblTrixFastDown[i] = EMPTY_VALUE;
      dblTrixSlowUp[i] = EMPTY_VALUE; dblTrixSlowDown[i] = EMPTY_VALUE;
      if (dblMain[i+1] < dblMain[i])
      {
         if (dblTrixFastUp[i+1] == EMPTY_VALUE) dblTrixFastUp[i+1] = dblMain[i+1];
         dblTrixFastUp[i] = dblMain[i];
      }
      else if (dblMain[i+1]>dblMain[i])
      {
         if (dblTrixFastDown[i+1] == EMPTY_VALUE) dblTrixFastDown[i+1] = dblMain[i+1];
         dblTrixFastDown[i] = dblMain[i];
      }
      else
      {
         if (dblTrixFastUp[i+1]   != EMPTY_VALUE) dblTrixFastUp[i]   = dblTrixFastUp[i+1];
         if (dblTrixFastDown[i+1] != EMPTY_VALUE) dblTrixFastDown[i] = dblTrixFastDown[i+1];
      }

      if(dblSignal[i+1]<dblSignal[i])
      {
         if (dblTrixSlowUp[i+1] == EMPTY_VALUE) dblTrixSlowUp[i+1] = dblSignal[i+1];
         dblTrixSlowUp[i] = dblSignal[i];
      }   
      else if (dblSignal[i+1]>dblSignal[i])
      {
         if (dblTrixSlowDown[i+1] == EMPTY_VALUE) dblTrixSlowDown[i+1] = dblSignal[i+1];
         dblTrixSlowDown[i] = dblSignal[i];
      }
      else
      {
         if (dblTrixSlowUp[i+1]   != EMPTY_VALUE) dblTrixSlowUp[i]   = dblTrixSlowUp[i+1];
         if (dblTrixSlowDown[i+1] != EMPTY_VALUE) dblTrixSlowDown[i] = dblTrixSlowDown[i+1];
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

//-----------------------------------------------------------------------------//
//  Get TimeFrame
//-----------------------------------------------------------------------------//
string GetPeriodName(int intPeriod)
{
   string strPeriod = "unknown";

   if (intPeriod == PERIOD_M1)  strPeriod = "M1";
   if (intPeriod == PERIOD_M5)  strPeriod = "M5";
   if (intPeriod == PERIOD_M15) strPeriod = "M15";
   if (intPeriod == PERIOD_M30) strPeriod = "M30";
   if (intPeriod == PERIOD_H1)  strPeriod = "H1";
   if (intPeriod == PERIOD_H4)  strPeriod = "H4";
   if (intPeriod == PERIOD_D1)  strPeriod = "D1";
   if (intPeriod == PERIOD_W1)  strPeriod = "W1";
   if (intPeriod == PERIOD_MN1) strPeriod = "MN";
   if (intPeriod == 0) strPeriod = GetPeriodName(Period());

   return(strPeriod);
}

Comments