#Parabolic 2TF

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

This tool is designed to provide traders with a multi-timeframe visual analysis by combining data from two different time periods simultaneously. Instead of looking at just one chart, it allows you to see the trend and signals for two different timeframes (for example, a 5-minute and a 15-minute chart) in a single view.

Core Logic Overview

The script functions by analyzing a specific technical signal—based on Parabolic SAR logic—across two distinct timeframes at once. It scans historical data to determine the current trend for both periods and maps them onto your current screen as visual markers.

Key Features of the Logic:

  • Dual-Timeframe Synchronization: The script looks at two different time intervals simultaneously (defined by user settings). This helps in identifying "confluence," which is when two different timeframes agree on a price direction, potentially increasing the reliability of a trade.
  • Trend Detection: It utilizes a secondary calculation to determine if the current market movement is "Up" or "Down." Based on this result, it assigns specific visual indicators to each timeframe.
  • Visual Mapping:
    • It places markers on the chart to represent the status of each timeframe.
    • The logic differentiates between the two timeframes using distinct colors (typically highlighting upward trends in one color and downward trends in another).
  • Dynamic On-Screen Labels: Beyond just markers, the script identifies the current state of both timeframes and generates text labels on the chart. These labels update dynamically to show which timeframe is currently dominant or trending, providing a quick "at-a-glance" summary for the user.
  • Historical Lookback: The tool processes a specific number of past bars (up to 1,500 by default) to ensure that the transition between trend changes is smooth and consistent as it moves across the chart.

Summary for the User

Essentially, this script acts as an information aggregator. It does the "heavy lifting" of checking two different charts for you, then brings that information together into one window. This allows you to see if a short-term trend matches a longer-term trend without having to flip back and forth between different windows.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
#Parabolic 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 DodgerBlue
#property indicator_color2 DodgerBlue
#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.02;
extern double Maximum = 0.20;
extern int Precision = 5;

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


//+------------------------------------------------------------------+
//| 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] = TF2;
   TF[1] = TF1;
  
   
   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_m15");
   if(ObjectFind("Para_Label_m15") != 0) {
   ObjectCreate("Para_Label_m15", OBJ_TEXT,WindowFind("Para 2TF ( M"+TF1+" )( M"+TF2+" )"), Time[0],indicator_maximum-0.50);
   ObjectSetText("Para_Label_m15", "                   M"+TF1+"",7, "Tahoma Bold",para_col5);
   } else{ ObjectMove("Para_Label_m15", 0, Time[0],indicator_maximum-0.50); }
   
         
  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-1.50);
   ObjectSetText("Para_Label_m5", "                   M"+TF2+"",7, "Tahoma Bold",para_col15);
   } else{ ObjectMove("Para_Label_m5", 0, Time[0],indicator_maximum-1.50); }
   
  
   }
}

Comments