DIBSv1.0
Download scriptThe DIBS v1.0 tool is designed to provide traders with a visual overview of specific market price behaviors and structural levels directly on their trading charts. Rather than cluttering the screen with complex mathematical formulas, this script focuses on identifying "Inside Bars" and providing clear temporal references for the current trading session.
Here is a breakdown of the primary functions provided by the tool:
1. Inside Bar Identification
The core logic of the script scans historical price data to identify Inside Bars. An inside bar occurs when the high and low prices of a specific candle are completely contained within the range of the previous candle (meaning the current candle's movement was narrower than the one before it).
- Visual Representation: When the script detects these bars, it highlights them on the chart using specific colors and styles.
- Trading Context: Identifying inside bars is a common technique used by traders to spot periods of consolidation or "coiling" price action, which often precede a significant breakout in either direction.
2. Daily Open Line Tracking
The script includes an automated drawing system that marks the Daily Opening Price. This allows you to see at a glance how the current price is performing relative to where the market started at the beginning of the day.
- Timezone Customization: The tool accounts for different timezones, allowing you to align the "Daily Open" with your specific local market hours.
- Visual Continuity: It draws a consistent line across the chart, helping traders gauge whether the current intraday trend is bullish (above the open) or bearish (below the open).
3. Real-Time Bar Countdown
To help with precise entry and exit timing, the script includes an information display that calculates exactly how much time remains before the current candle closes.
- Dynamic Updates: The text updates automatically on the chart, showing hours, minutes, and seconds.
- Timing Awareness: This is particularly useful for traders who prefer to execute orders at specific points in a candle's lifecycle or who need to monitor high-volatility periods near the close of a bar.
Summary of User Controls
The script offers several "On/Off" toggles, allowing you to customize your workspace:
- Show_IB: Enables or disables the highlighting of Inside Bars.
- Show_Daily_Open_Line: Enables or disables the horizontal reference line for the day's start.
- Show_Remain_Bar_Time: Enables or disables the live countdown timer on the chart display.
/*
* DIBSv1.0.mq4
*
* Thanks to Midnite (daily_open_line.mq4) and free84 (in&out.mq4)
*
* Remaining bar time added by NuckingFuts
**/
#property copyright "Copyright ©, free84, Midnite and NuckingFuts"
#property link "www.forexfactory.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 RoyalBlue
#property indicator_width1 2
#property indicator_color2 RoyalBlue
#property indicator_width2 2
#property indicator_color3 FireBrick
#property indicator_style3 2
#property indicator_width3 1
/* External settings */
extern bool Show_IB = true;
extern bool Show_Daily_Open_Line = true;
extern bool Show_Remain_Bar_Time = true;
extern int Timezone_Offset = 0;
/* Indicator buffers */
double ib1[];
double ib2[];
double OpenBuf[];
string IndName = "DIBS v1.0";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName(IndName);
SetIndexStyle(0, DRAW_HISTOGRAM, 0);
SetIndexStyle(1, DRAW_HISTOGRAM, 0);
SetIndexBuffer(0, ib1);
SetIndexBuffer(1, ib2);
SetIndexLabel(0, "IB");
SetIndexLabel(1, "IB");
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, OpenBuf);
SetIndexLabel(2, "OpenLine");
SetIndexEmptyValue(2, 0.0);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
string Cmnt = IndName;
if (Show_Remain_Bar_Time) Cmnt = Cmnt+"\n"+GetRemainingBarTime();
Comment(Cmnt);
static datetime prevtime = 0;
int shift;
int shift1;
int shift2;
double L, L1, H, H1;
if (Show_Daily_Open_Line)
{
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
int last_bar = Bars - counted_bars;
DrawDailyOpen(0, last_bar);
}
if (prevtime == Time[0]) return(0);
prevtime = Time[0];
for (shift = 0; shift < Bars; shift++)
{
shift1 = shift;
shift2 = shift + 1;
H = High[shift1];
H1 = High[shift2];
L = Low[shift1];
L1 = Low[shift2];
// Check IB's
if ((H <= H1) && (L >= L1))
{
if (Show_IB)
{
ib1[shift] = High[shift];
ib2[shift] = Low[shift];
}
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Draw daily open line |
//+------------------------------------------------------------------+
int DrawDailyOpen(int offset, int lastbar)
{
int shift;
int tzdiffsec = Timezone_Offset * 3600;
double barsper30 = 1.0*PERIOD_M30/Period();
bool ShowDailyOpenLevel = true;
lastbar = MathMin(Bars-20*barsper30-1, lastbar);
for (shift = lastbar; shift >= offset; shift--)
{
OpenBuf[shift] = 0;
if (ShowDailyOpenLevel)
{
if (TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec))
{
OpenBuf[shift] = Open[shift];
OpenBuf[shift+1] = 0;
}
else
{
OpenBuf[shift] = OpenBuf[shift+1];
}
}
}
return(0);
}
//+------------------------------------------------------------------+
// Show bar remaining time |
//+------------------------------------------------------------------+
string GetRemainingBarTime()
{
int min, sec, hr;
min = Time[0]+Period()*60-CurTime();
sec = min%60;
min = (min-min%60)/60;
string Com = "";
if (min > 59)
{
hr = min/60;
min = min%60;
Com = hr+" hour";
if (hr > 1) Com = Com + "s";
Com = Com+", ";
}
if (min > 0)
{
Com = Com+min + " minute";
if (min > 1 || min == 0) Com = Com + "s";
Com = Com +" and ";
}
Com = Com + sec + " second";
if (sec > 1) Com = Com + "s";
Com = Com +" remaining until bar close";
return(Com);
}
//+------------------------------------------------------------------+
Comments