_2523Parabolic 2TF

Download script
Author: Kalenzo - code adapted to bars by cja
_2523Parabolic 2TF

This script is a multi-timeframe analysis tool designed to help traders visualize market momentum and trend direction by comparing two different timeframes simultaneously. Instead of looking at just one chart period, this indicator synchronizes data from two specific periods (for example, the 5-minute and 15-minute charts) to provide a broader perspective on market movement.

How it Works

Dual Timeframe Synchronization The logic functions by scanning the price history of two different timeframes at once. It looks back at the most recent price bars and translates that information onto your current chart. This allows you to see what is happening on a "bigger picture" timeframe while you are looking at a smaller, more detailed one.

Trend Detection via Parabolic Movement The tool uses a specific calculation (based on a Parabolic SAR style logic) to determine if the market is in an upward or downward phase. It specifically checks for "crossover" points—moments where the trend direction flips.

Visual Indicators and Coding The script identifies these trend shifts and displays them as distinct markers:

  • It evaluates whether the trend is bullish (upward) or bearish (downward) on both timeframes.
  • It assigns specific colors to these trends to make them easy to distinguish at a glance.
  • It places visual labels on the indicator window to clearly identify which timeframe's data you are looking at (e.g., identifying the 5-minute trend versus the 15-minute trend).

Dynamic Labeling Beyond just drawing markers, the script dynamically updates text labels on your screen. These labels change color based on the current market sentiment of each timeframe. If the higher timeframe is bullish, the label will reflect that specific color; if it turns bearish, the label updates automatically to match the new trend.

Summary for the User

Essentially, this tool acts as a "trend filter." It takes complex data from two different timeframes, simplifies it into clear visual signals, and places them in one window. This helps you stay aligned with the dominant market direction, ensuring that your trades on a small timeframe are supported by the larger trend of the higher timeframe.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
_2523Parabolic 2TF
//+------------------------------------------------------------------+
//|                                               #Parabolic 2TF.mq4 |
//|                                                              cja |
//+------------------------------------------------------------------+
#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 3
#property indicator_buffers 4
#property indicator_color1 RoyalBlue
#property indicator_color2 RoyalBlue
#property indicator_color3 OrangeRed
#property indicator_color4 OrangeRed

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

extern int Maxbars   = 1500;
extern double Step = 0.013;
extern double Maximum = 0.20;
extern int Precision = 5;

extern int    TF1  = PERIOD_M15;
extern int    TF2  = PERIOD_M5;


//+------------------------------------------------------------------+
//| 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);
   
  
   
   IndicatorShortName("Para 2TF ( M"+TF1+" )( M"+TF2+" )");
   
   RefreshRates();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
 ObjectDelete("Para_Label_m1");ObjectDelete("Para_Label_m5");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int limit;
   int TF[] = {0,0};
   
   TF[0] = TF1;
   TF[1] = TF2;
  
   
   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;
     
      for (int jj=0; jj<2; 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 1:  ExtMapBuffer1[shift] = ind+1; break;
         case 0:  ExtMapBuffer2[shift] = ind+1; break;
               }
   } else {
         switch (ind)
         { 
            case 1:  ExtMapBuffer3[shift] = ind+1; break;
            case 0:  ExtMapBuffer4[shift] = ind+1; break;
            
         }
    
   color para_col15,para_col5;
  
   
   
   if(ExtMapBuffer1[0]>ExtMapBuffer3[0]){para_col5=indicator_color1;} 
   if(ExtMapBuffer3[0]>ExtMapBuffer1[0]){para_col5=indicator_color3;} 
   if(ExtMapBuffer2[0]>ExtMapBuffer4[0]){para_col15=indicator_color2;} 
   if(ExtMapBuffer4[0]>ExtMapBuffer2[0]){para_col15=indicator_color4;} 
     
   ObjectDelete("Para_Label_m5");
   if(ObjectFind("Para_Label_m5") != 0) {
   ObjectCreate("Para_Label_m5", OBJ_TEXT,WindowFind("Para 2TF ( M"+TF1+" )( M"+TF2+" )"), Time[0],indicator_maximum-0.50);
   ObjectSetText("Para_Label_m5", "                   M"+TF1+"",7, "Tahoma Narrow",para_col5);
   } else{ ObjectMove("Para_Label_m5", 0, Time[0],indicator_maximum-0.50); }
   
         
  ObjectDelete("Para_Label_m15");
   if(ObjectFind("Para_Label_m15") != 0) {
   ObjectCreate("Para_Label_m15", OBJ_TEXT,WindowFind("Para 2TF ( M"+TF1+" )( M"+TF2+" )"), Time[0],indicator_maximum-1.50);
   ObjectSetText("Para_Label_m15", "                   M"+TF2+"",7, "Tahoma Narrow",para_col15);
   } else{ ObjectMove("Para_Label_m15", 0, Time[0],indicator_maximum-1.50); }
   
  
   }
}

Comments