#MTF PCCI Bars

Author: Copyright � 2006, Eli hayun.
#MTF PCCI Bars

This tool is designed to help traders identify strong market trends by analyzing price action across multiple timeframes simultaneously. Instead of looking at a single chart, the script gathers data from four different time periods (ranging from 5 minutes to 1 hour) to determine if the overall market sentiment is aligned.

Core Logic Overview

The primary goal of the script is to achieve "confluence"—a situation where multiple indicators or timeframes agree on the same direction. It operates by checking the status of a specific external trend indicator across four distinct timeframes:

  • Timeframe Monitoring: The script constantly scans four specific intervals (5M, 15M, 30M, and 1H).
  • Trend Detection: For each of these timeframes, it checks whether the market is currently in an "Up" or "Down" state based on a secondary custom filter.
  • Aggregation: It counts how many of these four timeframes are moving in the same direction at any given moment.

How it Signals to the User

The script interprets the data into specific visual and audible cues:

  1. Visual Mapping: It uses "arrows" or markers on the chart to represent the state of each individual timeframe. This allows you to see at a glance which timeframes are bullish (upward) and which are bearish (downward).
  2. Trend Strength: The logic is specifically looking for high-probability scenarios. It monitors for moments where all four timeframes align perfectly in one direction (a full consensus).
  3. Alert System: One of the most practical features is its notification system. When the market shifts significantly—specifically when the current trend alignment changes at the start of a new bar—the script can trigger an audible sound and display a text comment on your screen.

Summary for Traders

Think of this script as a "multi-lane highway" monitor. Instead of just looking at one car (one timeframe), it watches four different lanes. It only gives you a clear signal when all four lanes are moving in the same direction. This helps filter out "noise" from smaller timeframes and ensures that your trading decisions are backed by a broader market trend.

Miscellaneous
Implements a curve of type %1It plays sound alerts
13 Views
0 Downloads
0 Favorites
#MTF PCCI Bars
//+------------------------------------------------------------------+
//|                                         #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