#Parabolic 4TF-1
Download scriptThis script is designed to serve as a multi-timeframe trend analysis tool. Its primary purpose is to aggregate and visualize market trends from four different time horizons simultaneously, allowing a trader to see "the big picture" at a single glance without switching between different charts.
Core Logic Overview
The tool operates by monitoring four specific timeframes (defined by the user, such as 30-minute, 1-hour, 4-hour, and Daily charts). Instead of looking at these one by one, the script pulls data from all four simultaneously and projects it onto your current active chart.
How the Analysis Works
1. Multi-Timeframe Data Collection The script reaches out to an external trend indicator (specifically a Parabolic SAR variation) across four different timeframes. It checks the status of the market on each of these periods to determine if the price action is currently moving in an upward or downward direction.
2. Trend Identification For every bar on your current chart, the script calculates:
- Whether the trend is positive (Bullish) or negative (Bearish).
- Which specific timeframe is showing that movement.
3. Visual Mapping and Labeling The logic then translates these findings into visual cues. It uses a system of "buffers" to keep track of the signals from each timeframe:
- Visual Indicators: The script places symbols (arrows) on the chart to represent the trend status for each of the four timeframes.
- Color Coding: It distinguishes between "Up" trends and "Down" trends using contrasting colors (typically Green for upward momentum and Red for downward momentum).
- Dynamic Labels: A unique feature of this script is its labeling system. It creates text labels on the chart that identify the specific timeframe being monitored. These labels dynamically change color based on whether that specific timeframe's trend is currently bullish or bearish.
Summary for the User
In simple terms, this script acts as a "Trend Dashboard." Instead of you having to manually check four different charts to see if the Daily, 4-Hour, 1-Hour, and 30-Minute trends are aligned, the script does this work for you. It gathers all that information, color-codes it, and displays it in one place, highlighting whether the market is in harmony across different time horizons or if there is a conflict between short-term and long-term price movements.
//+------------------------------------------------------------------+
//| #Parabolic 4TF.mq4 |
//+------------------------------------------------------------------+
#property copyright "Kalenzo - code adapted to bars by cja"
#property link "http://www.foreksik.prv.pl"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 5
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Green
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
extern int Maxbars = 1500;
extern double Step = 0.013;
extern double Maximum = 0.20;
extern int Precision = 4;
extern int TF1 = PERIOD_M30;
extern int TF2 = PERIOD_H1;
extern int TF3 = PERIOD_H4;
extern int TF4 = PERIOD_D1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,110);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,110);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,110);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,110);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,110);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexEmptyValue(4,0.0);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,110);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexEmptyValue(5,0.0);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,110);
SetIndexBuffer(6,ExtMapBuffer7);
SetIndexEmptyValue(6,0.0);
SetIndexStyle(7,DRAW_ARROW);
SetIndexArrow(7,110);
SetIndexBuffer(7,ExtMapBuffer8);
SetIndexEmptyValue(7,0.0);
IndicatorShortName("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )");
RefreshRates();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("Para_Label");ObjectDelete("Para_Label1");ObjectDelete("Para_Label2");
ObjectDelete("Para_Label3");ObjectDelete("Para_Label4");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int limit;
int TF[] = {0,0,0,0};
TF[0] = TF1;
TF[1] = TF2;
TF[2] = TF3;
TF[3] = TF4;
limit = MathMin(counted_bars,Maxbars);
if (limit ==0)
limit = Maxbars;
for (int ii=0; ii<limit; ii++)
{
ExtMapBuffer1[ii] = 0;
ExtMapBuffer2[ii] = 0;
ExtMapBuffer3[ii] = 0;
ExtMapBuffer4[ii] = 0;
ExtMapBuffer5[ii] = 0;
ExtMapBuffer6[ii] = 0;
ExtMapBuffer7[ii] = 0;
ExtMapBuffer8[ii] = 0;
for (int jj=0; jj<4; jj++)
{
int y = iBarShift(NULL, TF[jj], Time[ii]);
SetIndicator(GetCustomBars(TF[jj], y), jj, ii);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
bool GetCustomBars(int TF, int shift)
{
double h = iCustom(NULL,TF,"SAR Colour",Step,Maximum,Precision,0,shift);
double l = iCustom(NULL,TF,"SAR Colour",Step,Maximum,Precision,1,shift);
return(h<l);
}
void SetIndicator(bool isUP, int ind, int shift)
{
if (isUP)
{
switch (ind)
{
case 3: ExtMapBuffer1[shift] = ind+1; break;
case 2: ExtMapBuffer2[shift] = ind+1; break;
case 1: ExtMapBuffer3[shift] = ind+1; break;
case 0: ExtMapBuffer4[shift] = ind+1; break;
}
} else {
switch (ind)
{
case 3: ExtMapBuffer5[shift] = ind+1; break;
case 2: ExtMapBuffer6[shift] = ind+1; break;
case 1: ExtMapBuffer7[shift] = ind+1; break;
case 0: ExtMapBuffer8[shift] = ind+1; break;
}
/* ObjectDelete("Para");
ObjectCreate("Para", OBJ_LABEL,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), 0, 0);
ObjectSetText("Para","STD Parabolic [ M"+TF1+" ][ M"+TF2+" ][ M"+TF3+" ][ M"+TF4+" ]", 8, "Tahoma Narrow", White);
ObjectSet("Para", OBJPROP_CORNER, 0);
ObjectSet("Para", OBJPROP_XDISTANCE, indicator_maximum);
ObjectSet("Para", OBJPROP_YDISTANCE, indicator_maximum );*/
color para_col,para_col60,para_col15,para_col5;
string PARAlabel="";
if(ExtMapBuffer4[0]>ExtMapBuffer8[0]){para_col=indicator_color4;}
if(ExtMapBuffer8[0]>ExtMapBuffer4[0]){para_col=indicator_color8;}
if(ExtMapBuffer1[0]>ExtMapBuffer5[0]){para_col60=indicator_color1;}
if(ExtMapBuffer5[0]>ExtMapBuffer1[0]){para_col60=indicator_color5;}
if(ExtMapBuffer2[0]>ExtMapBuffer6[0]){para_col15=indicator_color2;}
if(ExtMapBuffer6[0]>ExtMapBuffer2[0]){para_col15=indicator_color6;}
if(ExtMapBuffer3[0]>ExtMapBuffer7[0]){para_col5=indicator_color3;}
if(ExtMapBuffer7[0]>ExtMapBuffer3[0]){para_col5=indicator_color7;}
int Trend_Trigger;
if(Trend_Trigger==true){PARAlabel=" STD Parabolic";}
if(Trend_Trigger==false){PARAlabel=" STD Parabolic";}
/*ObjectDelete("Para_Label4");
if(ObjectFind("Para_Label4") != 0) {
ObjectCreate("Para_Label4", OBJ_TEXT,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), Time[0],indicator_maximum-1);
ObjectSetText("Para_Label4", " "+PARAlabel+"",15, "Tahoma Narrow",para_col5);
} else{ ObjectMove("Para_Label4", 0, Time[0],indicator_maximum-1); } */
ObjectDelete("Para_Label");
if(ObjectFind("Para_Label") != 0) {
ObjectCreate("Para_Label", OBJ_TEXT,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), Time[0],indicator_maximum-0.50);
ObjectSetText("Para_Label", " M"+TF4+"",7, "Tahoma Narrow",para_col60);
} else{ ObjectMove("Para_Label", 0, Time[0],indicator_maximum-0.50); }
ObjectDelete("Para_Label1");
if(ObjectFind("Para_Label1") != 0) {
ObjectCreate("Para_Label1", OBJ_TEXT,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), Time[0],indicator_maximum-1.50);
ObjectSetText("Para_Label1", " M"+TF3+"",7, "Tahoma Narrow",para_col15);
} else{ ObjectMove("Para_Label1", 0, Time[0],indicator_maximum-1.50); }
ObjectDelete("Para_Label2");
if(ObjectFind("Para_Label2") != 0) {
ObjectCreate("Para_Label2", OBJ_TEXT,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), Time[0],indicator_maximum-2.5);
ObjectSetText("Para_Label2", " M"+TF2+"",7, "Tahoma Narrow",para_col5);
} else{ ObjectMove("Para_Label2", 0, Time[0],indicator_maximum-2.5); }
ObjectDelete("Para_Label3");
if(ObjectFind("Para_Label3") != 0) {
ObjectCreate("Para_Label3", OBJ_TEXT,WindowFind("Para 4TF ( M"+TF1+" )( M"+TF2+" )( M"+TF3+" )( M"+TF4+" )"), Time[0],indicator_maximum-3.50);
ObjectSetText("Para_Label3", " M"+TF1+"",7, "Tahoma Narrow",para_col);
} else{ ObjectMove("Para_Label3", 0, Time[0],indicator_maximum-3.50); }
}
}
Comments