InsideBar_v1

Download script
Author: Copyright � 2006, Eli Hayun
InsideBar_v1

This tool is designed to identify specific price action patterns on a trading chart by highlighting "Inside Bars." These are moments where the market shows a temporary contraction in volatility, suggesting a period of consolidation or a potential reversal.

The logic operates using two distinct identification methods to ensure the most accurate signals:

1. Structural Boundary Detection The script first looks at the physical boundaries of the candles. It identifies an "Inside Bar" when the current candle is completely contained within the price range of the previous candle. Specifically, if the current candle's low point is higher than the previous candle's low, and its high point is lower than the previous candle's high, the script flags this occurrence.

2. Relative Volatility Analysis To provide a more nuanced view, the tool also performs a comparative analysis of price movement over time. It measures the size (the "range") of the current candle and compares it against the sizes of the four preceding candles. If the current candle is smaller than all four of those previous candles, it is flagged as a significant contraction in movement.

Visual and Audible Alerts When the script confirms that a bar meets these criteria, it performs several actions to notify the trader:

  • Visual Markers: It plots specific data points on the chart to highlight the identified bars.
  • On-Screen Notifications: A text comment is automatically displayed on the trading window, showing the exact time the pattern occurred.
  • Audio Feedback: The system triggers a standard alert sound to provide immediate notification without requiring the user to constantly watch the screen.

Real-Time Monitoring The script is designed to be reactive. It monitors the market continuously and uses a "New Bar" detection system to ensure that alerts are only triggered once at the moment a new candle forms, preventing repetitive signals on the same price movement.

Miscellaneous
Implements a curve of type %1It plays sound alerts
10 Views
0 Downloads
0 Favorites
InsideBar_v1
//+------------------------------------------------------------------+
//|                                                    InsideBar.mq4 |
//|                                      Copyright © 2006, Eli Hayun |
//|                                          http://www.elihayun.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli Hayun"
#property link      "http://www.elihayun.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       NumPrevBars=4;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY, 4);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY, 4);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   for (int i=0; i<limit; i++)
   {
      ExtMapBuffer1[i] = 0; ExtMapBuffer2[i] = 0;
      if ( (Low[i] > Low[i+1]) && (High[i] < High[i+1]))
      {
         ExtMapBuffer1[i] = Close[i];
         ExtMapBuffer2[i] = Open[i];
      }
      double r0 = MathAbs(Open[i] - Close[i]);
      double r1 = MathAbs(Open[i+1] - Close[i+1]);
      double r2 = MathAbs(Open[i+2] - Close[i+2]);
      double r3 = MathAbs(Open[i+3] - Close[i+3]);
      double r4 = MathAbs(Open[i+4] - Close[i+4]);
      
      if (r0 < r1 && r0 < r2 && r0 < r3 && r0 < r4)
      {
         ExtMapBuffer1[i] = Close[i];
         ExtMapBuffer2[i] = Open[i];
      }       
   }
   if (ExtMapBuffer1[1]  != 0 && NewBar())
   {
      Comment(TimeToStr(Time[0])," Inside bar"); Print(Symbol(), " Inside bar");
      PlaySound("expert.wav");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

bool NewBar()
{
   static datetime dt  = 0;
   if (dt != Time[0])
   {
      dt = Time[0];
      return(true);
   }
   return(false);
}


Comments