Candles_HigherTimeFrameBar

Download script
Author: Copyright � 2005, Miramaxx.
Candles_HigherTimeFrameBar

This tool is designed to provide traders with a multi-dimensional view of the market by overlaying price data from higher timeframes onto their current chart. It allows you to visualize the "big picture" without having to constantly switch between different windows or tabs, making it easier to identify broader trends and significant price movements at a glance.

Core Functionality

The script works by identifying a higher timeframe (such as Daily, Weekly, or 4-hour charts) and projecting those specific bars onto your active lower timeframe chart (such as a 15-minute or 1-hour chart). It calculates the opening and closing prices of these larger candles and draws them as visual elements on your screen.

Key Features and Logic:

  • Timeframe Customization: You can manually select which higher timeframe you wish to view. The script includes a built-in validation system to ensure that the chosen timeframe is actually larger than your current chart; if you try to project a smaller timeframe onto a larger one, the tool will notify you with an error message.
  • Visual Representation:
    • Body Visualization: The main body of the higher timeframe candle is represented by a rectangle. This gives you a clear sense of the price range covered during that period.
    • High/Low Markers: To provide a complete picture of price volatility, the script also identifies the highest and lowest points reached during those periods, marking them with distinct trend lines.
  • Dynamic Color Coding: The tool automatically distinguishes between "Bullish" (upward) and "Bearish" (downward) movements. It applies specific colors to the candles based on whether the price closed higher or lower than it opened, allowing for instant recognition of market sentiment.
  • Customizable Display: You can choose how many historical bars from the higher timeframe you want to see at once and determine whether these markings appear as background elements or on top of your current price action.

How it Benefits Your Trading:

By using this tool, you can see how the current "minor" price movements fit into the "major" market structure. It helps in identifying support and resistance levels that are only visible on larger scales and ensures that your short-term trades are aligned with the prevailing long-term trend.

Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
13 Views
0 Downloads
0 Favorites
Candles_HigherTimeFrameBar
//+------------------------------------------------------------------+
//| Candles_HigherTimeFrameBar                           LargeTF.mq4 |
//|                                      Copyright © 2005, Miramaxx. |
//|                                    mailto: morrr2001[dog]mail.ru |
//+------------------------------------------------------------------+
//|Ïîñòðîåíèå íà ãðàôèêå ñâå÷åé ñòàðøåãî òàéìôðåéìà.                 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Miramaxx."
#property link "mailto: morrr2001[dog]mail.ru"
//----
#property indicator_chart_window
//----
extern string TF="240";
extern int CountBars=30;
extern color Bear=Maroon;
extern color Bull=MidnightBlue;
extern bool backgr= false;
//----
   datetime time1;
   datetime time2;
   double open_price,close_price;
   int bar_tf;
   int PeriodName=0;
   int num=0;
   string error=" error setting parameter: TF \n example: for H1 chart enter parameter: D1";

//   string error="Ïàðàìåòð TF çàäàí íå âåðíî \nÏðèìåð: äëÿ ÷àñîâîãî ãðàôèêà âûáåðèòå ïàðàìåòð D1.";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   void ObjDel()
  {
   for(;num>=0;num--)
      ObjectDelete("Objtf"+num);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
 if (TF=="M1"||TF=="m1"||TF=="1") PeriodName=PERIOD_M1; // in Minutes or  as MT4 Periodicity Tab  //â òîì æå ïîðÿäêå, ÷òî è êíîïêè íà ïàíåëè
 else
    if (TF=="M5"||TF=="m5"||TF=="5") PeriodName=PERIOD_M5;
    else
       if (TF=="M15"||TF=="m15"||TF=="M5"||TF=="15")PeriodName=PERIOD_M15;
       else
          if (TF=="M30"||TF=="m30"||TF=="30")PeriodName=PERIOD_M30;
          else
             if (TF=="H1"||TF=="h1"||TF=="60") PeriodName=PERIOD_H1;
             else
               if (TF=="H4"||TF=="h4"||TF=="240") PeriodName=PERIOD_H4;
               else
                  if (TF=="D1"||TF=="d1"||TF=="1440") PeriodName=PERIOD_D1;
                  else
                     if (TF=="W1"||TF=="w1"||TF=="10080") PeriodName=PERIOD_W1;
                     else
                        if (TF=="MN"||TF=="mn"||TF=="43200") PeriodName=PERIOD_MN1;
                        else
                             {
                              Comment(error);
                              return(0);
                             }
   Comment("HigherTF (",TF,") Bar");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjDel();
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i;
   ObjDel();
   num=0;
//----
   if (PeriodName<=Period())
     {
      Comment(error);
      return(0);
     }
//----
   for(bar_tf=CountBars;bar_tf>=0;bar_tf--)
     {
      time1=iTime(NULL,PeriodName,bar_tf);
      i=bar_tf-1;
      if (i<0)
         time2=Time[0];
      else
         time2=iTime(NULL,PeriodName,i)-Period()*60;
      open_price=iOpen(NULL,PeriodName,bar_tf);
      close_price=iClose(NULL,PeriodName,bar_tf);
//---
      ObjectCreate("Objtf"+num,OBJ_RECTANGLE,0,time1,open_price,time2,close_price);
               ObjectSet("Objtf"+num, OBJPROP_WIDTH, 3);
              ObjectSet("Objtf"+num, OBJPROP_BACK, backgr);

      if (time2-time1<PeriodName*60/2)
         time2=Time[0];
      else
         time2=time1+PeriodName*60/2;
      num++;
//----      
      ObjectCreate("Objtf"+num,OBJ_TREND,0,time2,iHigh(NULL,PeriodName,bar_tf),time2,iLow(NULL,PeriodName,bar_tf));
      ObjectSet("Objtf"+num, OBJPROP_WIDTH, 3);
      ObjectSet("Objtf"+num, OBJPROP_RAY, false);
//----      
      if (close_price>open_price)
        {
         ObjectSet("Objtf"+(num-1),OBJPROP_COLOR, Bull);
         ObjectSet("Objtf"+num,OBJPROP_COLOR, Bull);
         ObjectSet("Objtf"+num, OBJPROP_WIDTH, 3);


        }
      else
        {
         ObjectSet("Objtf"+(num-1),OBJPROP_COLOR, Bear);
         ObjectSet("Objtf"+num,OBJPROP_COLOR, Bear);
         ObjectSet("Objtf"+num, OBJPROP_BACK, false);

        }
      num++;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments