#MTF Triggerlines Bars_001

Download script
Author: Copyright � 2006, Eli hayun.
#MTF Triggerlines Bars_001

This script is a multi-timeframe analysis tool designed to help traders identify specific momentum signals across four different time periods simultaneously. Instead of looking at just one chart at a time, it synchronizes data from various intervals—specifically the 5-minute, 15-minute, 30-minute, and 1-hour charts—to provide a comprehensive view of market trends.

Core Logic and Functionality

The primary purpose of this tool is to detect "triggers" based on a specific custom indicator (named "Triggerlines"). It scans the historical data of multiple timeframes and translates those signals into visual markers on your current chart. Here is how the logic flows:

1. Multi-Timeframe Synchronization The script automatically looks back at four distinct timeframes defined in the settings. It maps the data from these larger or smaller intervals onto your current view, ensuring that you can see what is happening on the 1-hour chart while you are looking at a much faster timeframe.

2. Signal Detection For every point in time, the script checks for two specific values from the "Triggerlines" indicator:

  • It looks for a "High" signal value.
  • It looks for a "Low" signal value.
  • The Logic: If the "High" value is lower than the "Low" value (a specific crossover or conditional state), it identifies this as a significant market event or "trigger."

3. Visual Categorization Once a trigger is detected on one of the timeframes, the script assigns it to one of two categories based on the direction or nature of the signal:

  • Upward/Positive Triggers: These are assigned to specific visual buffers (represented by red markers).
  • Downward/Negative Triggers: These are assigned to separate visual buffers (represented by blue markers).

4. Data Mapping and Display The script organizes these signals so that each timeframe has its own dedicated marker type. This allows a trader to distinguish at a glance which timeframe is providing a signal. By plotting these on a separate window, the tool acts as a summary dashboard, showing the cumulative "triggers" from all four timeframes in one organized area of the screen.

Summary for the User

Essentially, this script saves you from having to switch between four different tabs or windows. It does the heavy lifting by constantly monitoring the 5m, 15m, 30m, and 1h charts for you, identifying specific "Triggerline" conditions, and displaying them as a unified set of visual cues on your primary screen.

Miscellaneous
Implements a curve of type %1
6 Views
0 Downloads
0 Favorites
#MTF Triggerlines Bars_001
//+------------------------------------------------------------------+
//|                                         #MTF Triggerlines 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 = "Triggerlines";

extern int Maxbars   = 1000;



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;
      limit=Bars-counted_bars;
   
   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, Rperiod, LSMA_Period, 5, shift);
   double l = iCustom(Symbol(), TF, CustomIndicator, Rperiod, LSMA_Period, 6, 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;
         }
   }
}

Comments