THV T3 Trix MTF
Download scriptThis script is a specialized technical analysis tool designed for the MetaTrader platform. It focuses on visualizing momentum and trend direction by blending data from different timeframes into a single, easy-to-read visual display.
Core Functionality
The primary purpose of this tool is Multi-Timeframe (MTF) Analysis. Rather than forcing you to switch back and forth between different charts (such as moving from a 15-minute chart to a 4-hour chart), the script pulls data from a higher timeframe and projects it onto your current viewing screen. This allows you to keep an eye on the "big picture" trends while making decisions on smaller, more active timeframes.
Key Components of the Logic
The script processes two distinct types of data signals simultaneously:
- Fast Momentum (Trix Fast): This is displayed as a histogram. It reacts more quickly to recent price changes, helping you identify immediate shifts in momentum. The script automatically assigns colors to this data—typically showing "Up" movements in one color and "Down" movements in another—to make the trend direction instantly recognizable.
- Slow Momentum (Trix Slow): This is displayed as a line. It is designed to be smoother and less reactive than the fast momentum, providing a clearer view of the underlying long-term trend. Like the fast version, it differentiates between upward and downward movements using specific colors.
How the Data is Processed
- Time Synchronization: The script looks at the "Base Code" (the original Trix T3 calculation) and aligns the data points from your chosen higher timeframe with the exact time on your current chart. This ensures that the information you see is accurate to the current moment.
- Trend Identification: The logic constantly compares the current value of the indicators against their previous values.
- If the value is rising, it paints or draws the data in an "Up" color.
- If the value is falling, it paints or draws the data in a "Down" color.
- If there is no change, it maintains the previous color to ensure a smooth visual transition.
- Visual Clarity: By separating these into four distinct buffers (Fast Up, Fast Down, Slow Up, and Slow Down), the script provides a comprehensive "health check" of the market's momentum at a glance.
Summary for the User
Essentially, this tool acts as a multi-layered filter. It takes complex mathematical trend data from a larger timeframe and simplifies it into a color-coded visual map on your current screen. It allows you to see both the immediate "pulse" of the market (via the Fast Histogram) and the broader "direction" of the market (via the Slow Line) at the same time.
/*
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...
*/
#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 = 60;
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
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);
//----
string strTimeFrame = GetPeriodName(TimeFrame);
indicatorName = "MTF Trix (" + strTimeFrame + ")";
IndicatorShortName(indicatorName);
//----
return(0);
}
//+------------------------------------------------------------------+
//| start()
//+------------------------------------------------------------------+
int start()
{
datetime dtmTime[];
int i;
int j;
int intMaxVal;
int intTotBars = IndicatorCounted();
intMaxVal = Bars - intTotBars;
ArrayCopySeries(dtmTime, MODE_TIME, Symbol(), TimeFrame);
ArrayResize(dblMain, intMaxVal);ArrayResize(dblSignal, intMaxVal);
j = 0;
// Calculate TRIX Values //
for(i=0; i<intMaxVal; i++)
{
if (Time[i] < dtmTime[j]) j++;
dblMain[i]=iCustom(NULL, TimeFrame, strBaseCodeFileName, TrixNumberOfBars, A_t3_period, B_t3_period_ac, MODE_MAIN, j);
dblSignal[i]=iCustom(NULL, TimeFrame, strBaseCodeFileName, TrixNumberOfBars, A_t3_period, B_t3_period_ac, MODE_SIGNAL, j);
}
// Coloring //
for(i=intMaxVal-2; 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 = "MN1";
if (intPeriod == 0) strPeriod = GetPeriodName(Period());
return(strPeriod);
}
Comments