Price_Bars_MTF

Download script
Author: Copyright � 2006, Keris2112
Price_Bars_MTF

This script is a specialized visual tool designed for the MetaTrader trading platform. Its primary purpose is to project historical price data from higher timeframes directly onto your current chart, allowing you to see "the big picture" without constantly switching between different tabs or windows.

Core Functionality

The tool captures key price points—specifically the Open, High, Low, and Close prices—from a specific timeframe that you choose (such as Daily, Weekly, or Hourly). It then plots these values as visual indicators on your active chart.

By doing this, it helps traders identify significant price levels and structural trends from larger timeframes while they are analyzing smaller, more detailed price movements.

How the Logic Works

The script operates through the following logical steps:

  • Timeframe Synchronization: You can select a specific timeframe to monitor (e.g., seeing Daily candles while looking at a 15-minute chart). If no specific timeframe is chosen, it defaults to the one you are currently viewing.
  • Data Retrieval: The script looks back through historical data up to a user-defined limit (defaulting to 1,500 bars). It scans the history of the selected "higher" timeframe to find matching time stamps for your current view.
  • Dynamic Price Mapping: For every historical candle in that higher timeframe, the script identifies four specific price points:
    1. The Opening price.
    2. The Closing price.
    3. The Highest price reached.
    4. The Lowest price reached.
  • Visual Representation: The script renders these prices as histograms on your screen. It intelligently distinguishes between "bullish" candles (where the close is higher than the open) and "bearish" candles (where the close is lower than the open) to ensure the High and Low values are mapped correctly to your visual display.
  • Custom Positioning: The tool includes a "Shift" feature, which allows you to physically move the visual markers forward or backward on the chart. This provides flexibility in how you align the data with your current trading workspace.

Key Benefit for Traders

Instead of manually calculating where a Daily candle started or ended while zoomed into a minute-by-minute view, this script automates that process. It provides a clear visual "overlay" of major market boundaries, helping to identify support, resistance, and trend direction across multiple layers of time simultaneously.

Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Price_Bars_MTF
//+------------------------------------------------------------------+
//|                                                   Price_MTF .mq4 |
//|                                      Copyright © 2006, Keris2112 |
//| 2008forextsd    ki                                         pubic |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link   "public" // Keris f-la; IgorAd Mladen; KI put together :)

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Maroon     
#property indicator_color2 RoyalBlue  
#property indicator_color3 Maroon     
#property indicator_color4 RoyalBlue  
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 5
#property indicator_width4 5

//----
extern int TimeFrame = 0;
extern int Shift=0;
extern int xShift=0;
extern int MaxBarsToCount   = 1500;

extern string note_timeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";

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

//+------------------------------------------------------------------+

int init()
  {
//---- 
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexBuffer(3, ExtMapBuffer4);

   SetIndexStyle(0,DRAW_HISTOGRAM); 
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);

//----      
  if(TimeFrame==0) TimeFrame = Period();
  SetIndexShift(0, Shift+xShift*TimeFrame/Period());
  SetIndexShift(1, Shift+xShift*TimeFrame/Period());
  SetIndexShift(2, Shift+xShift*TimeFrame/Period());
  SetIndexShift(3, Shift+xShift*TimeFrame/Period());
  
   switch(TimeFrame)
    {
      case 1 : string TimeFrameStr= "M1";  break;
      case 5 : TimeFrameStr=        "M5";  break;
      case 15 : TimeFrameStr=       "M15"; break;
      case 30 : TimeFrameStr=       "M30"; break;
      case 60 : TimeFrameStr=       "H1";  break;
      case 240 : TimeFrameStr=      "H4";  break;
      case 1440 : TimeFrameStr=     "D1";  break;
      case 10080 : TimeFrameStr=    "W1";  break;
      case 43200 : TimeFrameStr=    "MN1"; break;
      default : TimeFrameStr=    "CurrTF";
    }

    IndicatorShortName("Price ["+TimeFrameStr+"]");  
    if (TimeFrame<Period()) TimeFrame=Period();
   
   return(0);
 }

//+------------------------------------------------------------------+

int deinit()
  {
   return(0);
  }

//+------------------------------------------------------------------+

int start()
  {
   double open, close, high, low;
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   limit= Bars-counted_bars;
   limit= MathMax(limit,TimeFrame/Period());
   limit= MathMin(limit,MaxBarsToCount);

   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;

      open = iOpen (NULL,TimeFrame,y);
      close= iClose(NULL,TimeFrame,y);
      high = iHigh (NULL,TimeFrame,y);
      low  = iLow  (NULL,TimeFrame,y);
 
      if (open<close) 
        {
         ExtMapBuffer1[i]=low;
         ExtMapBuffer2[i]=high;
        } 
      else
        {
         ExtMapBuffer1[i]=high;
         ExtMapBuffer2[i]=low;
        } 
      ExtMapBuffer3[i]=open;
      ExtMapBuffer4[i]=close;
     }
   return(0);
  }

//+------------------------------------------------------------------+

Comments