Price_BarsM2_MTF_v1
Download scriptThis tool is designed for traders who need to visualize price action from higher timeframes directly on their current trading chart. Essentially, it bridges the gap between different time periods (such as viewing Daily candle data while looking at a 1-minute chart), allowing you to see "the big picture" without constantly switching windows.
Core Functionality
The primary purpose of this script is to project price data from a specific higher timeframe onto your active chart. It identifies the key price levels of those larger candles—specifically the Open, High, Low, and Close prices—and displays them as visual histograms.
By using this tool, you can see where a previous daily or hourly candle started, ended, and reached its extremes, helping you identify significant support, resistance zones, and trend directions more effectively.
Key Features & Logic
- Multi-Timeframe Projection: You can choose exactly which timeframe you want to monitor (e.g., H1, H4, Daily, etc.). The script automatically fetches the relevant data for that period and maps it onto your current screen.
- Smart Alignment: To ensure the data is easy to read, the script includes logic to synchronize the timeframes. It can automatically adjust the "shift" of the visual markers so that they align perfectly with the closing times of the larger candles.
- Visual Differentiation: The script uses four distinct buffers to track price points:
- It identifies whether a candle was bullish (closed higher than it opened) or bearish (closed lower).
- Based on that movement, it plots the High and Low points as specific visual markers.
- It simultaneously tracks the Open and Close prices to provide a complete overview of the price range.
- Customizable Visibility:
- Historical Depth: You can set a limit on how many past bars the script should calculate, ensuring the platform remains responsive.
- Single vs. Multiple Display: It offers options to toggle between viewing specific bar data or broader information based on your trading style.
How it Benefits the Trader
Instead of guessing where a 4-hour candle's high was while you are scalping on a lower timeframe, this tool puts those boundaries directly in front of you. It provides a constant visual reference for "higher-order" price action, making it easier to spot potential breakout areas or retracement levels at a glance.
//+------------------------------------------------------------------+
//| Price_MTF .mq4 |
//| Copyright © 2006, Keris2112 |
//| 2008forextsd ki pubilc |
//+------------------------------------------------------------------+
#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 Red
#property indicator_color2 DodgerBlue
#property indicator_color3 Red
#property indicator_color4 DodgerBlue
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 5
#property indicator_width4 5
//----
extern int TimeFrame = 60;
extern int Shift=0;
extern int xShift=0;
extern bool SetShift0ToTFBarCloseTime = true;
extern bool ShowMultipleBars = false;
extern int MaxBarsToCount = 1500;
extern string note_timeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
//----
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int ShiftToBarClose;
//+------------------------------------------------------------------+
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();
if(SetShift0ToTFBarCloseTime)ShiftToBarClose =TimeFrame/Period()-1;
//----
SetIndexShift(0, Shift+xShift*TimeFrame/Period()+ShiftToBarClose);
SetIndexShift(1, Shift+xShift*TimeFrame/Period()+ShiftToBarClose);
SetIndexShift(2, Shift+xShift*TimeFrame/Period()+ShiftToBarClose);
SetIndexShift(3, Shift+xShift*TimeFrame/Period()+ShiftToBarClose);
//----
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= "TF0";
}
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 (!ShowMultipleBars)
{
if(Time[i]==TimeArray[y])
{
if (open<close)
{
ExtMapBuffer1[i]=low;
ExtMapBuffer2[i]=high;
}
else
{
ExtMapBuffer1[i]=high;
ExtMapBuffer2[i]=low;
}
ExtMapBuffer3[i]=open;
ExtMapBuffer4[i]=close;
}
}
else
{
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