_2523MTF PCCI Bars

Download script
Author: Copyright � 2006, Eli hayun.
_2523MTF PCCI Bars

The #MTF Hull Trend Bars script is a multi-timeframe analysis tool designed to provide traders with a visual representation of market direction by aggregating data from four different timeframes simultaneously. Instead of looking at a single chart, this tool scans multiple periods (specifically the 5-minute, 15-minute, 30-minute, and 1-hour intervals) to determine if the overall trend is aligned.

Core Logic and Functionality

Multi-Timeframe Coordination The primary logic of this script is "confluence." It examines four specific timeframes to see if they are moving in the same direction. By checking multiple horizons at once, the tool helps filter out "noise" from smaller price movements, aiming to identify stronger, more reliable trends that persist across different durations.

Trend Detection Mechanism The script relies on an external custom indicator (referred to as "PCCI-as a filter") to determine whether the market is currently in an upward or downward state for each timeframe. It looks at the data provided by this external source and categorizes the trend:

  • If the external indicator signals an upward movement, the script registers a positive level.
  • If it signals a downward movement, it registers a negative level.

Visual Representation The tool uses eight distinct buffers to plot information on your chart. These act as visual markers (arrows) that represent the status of each timeframe. By observing these markings, a trader can quickly see at a glance how many timeframes are currently in agreement (e.g., all four showing "up" or all four showing "down").

Alert System and Signal Logic One of the key features of this script is its ability to notify the user of significant trend shifts. The logic follows these specific rules:

  1. Agreement Check: It monitors the current state of all four timeframes.
  2. Directional Change: An alert is triggered specifically when all four timeframes reach a unanimous consensus (all upward or all downward) while simultaneously detecting a shift from the previous state.
  3. Notification: When this high-probability alignment occurs, the script provides an audible sound alert and displays a "Changing direction" message on the screen.

Summary for the Trader

This script simplifies complex multi-timeframe analysis into a single visual dashboard. Rather than forcing you to switch between four different charts to see if the 5-minute and 1-hour trends match, it does that work automatically in the background. It highlights moments where all timeframes are "in sync," helping you identify high-probability trend entries while filtering out contradictory signals from individual timeframes.

Miscellaneous
Implements a curve of type %1It plays sound alerts
3 Views
0 Downloads
0 Favorites
_2523MTF PCCI Bars
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                         #MTF Hull Trend Bars.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun."
#property link      "http://www.elihayun.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 5
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Blue
#property indicator_color6 Blue
#property indicator_color7 Blue
#property indicator_color8 Blue
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];


extern string  CustomIndicator = "PCCI-as a filter";

extern int Maxbars   = 1000;
extern bool UseAlert = true;




extern int Rperiod = 15;
extern int LSMA_Period = 5;

extern int    TF1  = PERIOD_M5;
extern int    TF2  = PERIOD_M15;
extern int    TF3  = PERIOD_M30;
extern int    TF4  = PERIOD_H1;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,117);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,117);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,117);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,117);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,117);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,117);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexEmptyValue(5,0.0);
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,117);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexEmptyValue(6,0.0);
   SetIndexStyle(7,DRAW_ARROW);
   SetIndexArrow(7,117);
   SetIndexBuffer(7,ExtMapBuffer8);
   SetIndexEmptyValue(7,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   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;
   
   int levels  = 0;
   int pLevels = 0;
   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]);
         bool isUp;
         isUp = GetCustomBars(TF[jj], y);
         SetIndicator(isUp, jj, ii);
         if (ii == 0 && isUp)
            levels++;
         if (ii == 0 && !isUp)
            levels--;

         if (ii == 1 && isUp)
            pLevels++;
         if (ii == 1 && !isUp)
            pLevels--;
      }
      if (ii==1)
         if (((levels == 4) || (levels == -4)) && MathAbs(pLevels) != 4)
            if (UseAlert && NewBar())
            {
               PlaySound("expert.wav");
               Comment("Changing direction");
            }
   } 
//----
   return(0);
  }
//+------------------------------------------------------------------+

bool GetCustomBars(int TF, int shift)
{

   double h = iCustom(Symbol(), TF, CustomIndicator, 0, shift);
   
   return(h<0);
}

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;
         }
   }
}


bool NewBar()
{
   int p = 0;
   static datetime dtCurrTime = 0;
   
   if (iTime(NULL, p, 0) != dtCurrTime)
   {
      dtCurrTime = iTime(NULL, p , 0);
      return(true);
   }
   return(false);
}


Comments