MTF_FXSErgoCCITrig_L_4TF_BarsM6

Download script
Author: Copyright � 2006, Eli hayun.
MTF_FXSErgoCCITrig_L_4TF_BarsM6

This script is designed to act as a multi-timeframe trend analyzer. Its primary purpose is to scan several different time horizons simultaneously and project their signals onto your current chart, allowing you to see the "big picture" of the market without having to switch between different windows.

Core Functionality

The tool monitors four specific timeframes (ranging from H1 to Weekly) and evaluates the market trend on each one. It looks for specific conditions defined by a secondary custom indicator to determine if the price action is moving in an upward or downward direction.

How the Logic Works

  • Multi-Timeframe Synchronization: Instead of just showing you what is happening right now on your current screen, the script "reaches out" to higher timeframes. It calculates whether the trend is bullish or bearish on the 1-Hour, 4-Hour, Daily, and Weekly charts all at once.
  • Signal Detection: The script checks these various timeframes for specific price crossovers or movements. If a timeframe meets the "Up" criteria, it marks a positive signal; if it meets the "Down" criteria, it marks a negative signal.
  • Visual Representation: The results are displayed as distinct visual markers (arrows) on your chart. By observing these markers, you can instantly see how many different timeframes are currently in agreement. For example, if all signals are aligned in one direction, it suggests a strong, synchronized trend across both short-term and long-term perspectives.
  • Data Smoothing: To ensure the visual information is easy to read, the script includes a "buffer refresh" mechanism. This helps maintain a consistent visual flow on your chart, ensuring that the data remains coherent even when you are viewing smaller timeframes compared to the larger ones being analyzed.

Summary for the User

Think of this tool as a "Trend Dashboard." Rather than forcing you to manually check four different charts to see if the Weekly trend matches the Hourly trend, this script does that work for you. It aggregates those perspectives into a single set of signals on your screen, helping you identify when multiple timeframes are aligned in the same direction.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
MTF_FXSErgoCCITrig_L_4TF_BarsM6
//+------------------------------------------------------------------+
//|                                         MTF_Supertrend2_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 6
#property indicator_buffers 8
#property indicator_color1 Crimson
#property indicator_color2 Maroon
#property indicator_color3 FireBrick
#property indicator_color4 Maroon
#property indicator_color5 SpringGreen
#property indicator_color6 MediumSpringGreen
#property indicator_color7 MediumSeaGreen
#property indicator_color8 SeaGreen
//   IndicatorDigits(2);

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];


extern string  CustomIndicator = "FXSErgoCCITrig[L]";


extern int pq =2;
extern int pr = 10;
extern int ps = 5;
extern int trigger =3;
extern int ModeMA =2;
extern string note_TF = "M30,60H1,240H4,1440D1,10080W1,43200MN1";
extern string MA_Method = "ModeMa(SMA0,EMA1,SmmMA2,LWMA3)";
extern string MA_Price = "Price(OCHLMdTpWg)";
extern int Maxbars=1000;

//extern int NbPeriods = 10;
//extern int LSMA_Period = 5;

extern int    TF4  = PERIOD_H1;
extern int    TF3  = PERIOD_H4;
extern int    TF2  = PERIOD_D1;
extern int    TF1  = PERIOD_W1;

//+------------------------------------------------------------------+
//| 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);
//----
   SetIndexLabel(0,"FXSErgoCCITr("+TF4+")");
   SetIndexLabel(1,"FXSErgoCCITr("+TF3+")");
   SetIndexLabel(2,"FXSErgoCCITr("+TF2+")");
   SetIndexLabel(3,"FXSErgoCCITr("+TF1+")");
   SetIndexLabel(4,"FXSErgoCCITr("+TF4+")");
   SetIndexLabel(5,"FXSErgoCCITr("+TF3+")");
   SetIndexLabel(6,"FXSErgoCCITr("+TF2+")");
   SetIndexLabel(7,"FXSErgoCCITr("+TF1+")");
   IndicatorDigits(1);



//---
   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;
limit=Bars-counted_bars;
limit=MathMax(limit,TF1/Period());
limit=MathMax(limit,TF2/Period());
limit=MathMax(limit,TF3/Period());
limit=MathMax(limit,TF4/Period());
limit=MathMin(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(Symbol(), TF, CustomIndicator, 2,10,5,3,2,0, shift);
   double l = iCustom(Symbol(), TF, CustomIndicator, 2,10,5,3,2,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;
         }
   }

  //----  Refresh buffers ++++++++++++++++++++ upgrade by Raff  
 int TimeFrame,TimeArray[],i;   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
 /********************************************************  
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  


      ExtMapBuffer1[i] = ExtMapBuffer1[0];
      ExtMapBuffer2[i] = ExtMapBuffer2[0];
      ExtMapBuffer3[i] = ExtMapBuffer3[0];
      ExtMapBuffer4[i] = ExtMapBuffer4[0];
      ExtMapBuffer5[i] = ExtMapBuffer5[0];
      ExtMapBuffer6[i] = ExtMapBuffer6[0];
      ExtMapBuffer7[i] = ExtMapBuffer7[0];
      ExtMapBuffer8[i] = ExtMapBuffer8[0];

//----
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++  Raff  
 


   return(0);
  }

Comments