_!InsideBars
Download scriptThis tool is designed to automatically identify specific price action patterns on your trading charts, specifically focusing on "Inside Bars." By scanning a designated number of historical candles, the script highlights moments where price volatility contracted, which can often signal an upcoming breakout or a period of consolidation.
How the Logic Works
1. Pattern Recognition The script continuously monitors the relationship between consecutive candles. It looks for a specific occurrence where a candle is completely contained within the boundaries of the previous candle. Specifically, it checks if:
- The high point of the current candle is lower than the high of the previous one.
- The low point of the current candle is higher than the low of the previous one.
2. Automated Visual Markers When the script identifies this "Inside Bar" pattern, it automatically places visual markers on your chart to provide immediate clarity:
- Boundary Points: It establishes the upper and lower limits of the identified pattern.
- Support and Resistance Levels: The tool calculates specific price levels based on these bars. It calculates a midpoint (an average of the high and low) and identifies the lowest points within the surrounding price action to help define potential "stop" or "pivot" zones.
3. Chart Coverage You can customize how far back into the past the script looks by adjusting the bar count settings. This allows you to focus on recent market behavior or scan a larger historical dataset to identify recurring patterns.
Summary for Traders
Instead of manually measuring every candle to see if one fits inside another, this script does the heavy lifting for you. It filters out the noise and highlights these specific structural shifts, marking the price boundaries and midpoints automatically so you can more easily spot potential trading opportunities where the market is "coiling" before a move.
//+------------------------------------------------------------------+
//| #!InsideBars.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 DeepPink
#property indicator_color5 Blue
#property indicator_color6 Aqua
#property indicator_color7 Red
#property indicator_color8 DarkViolet
#property indicator_width1 0
#property indicator_width2 0
#property indicator_width3 0
#property indicator_width4 0
#property indicator_width5 0
extern int Barss = 500;
double upline[],downline[];
double upstopline[],downstopline[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,upline);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,241);
SetIndexLabel(0,"upline");
SetIndexBuffer(1,downline);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,242);
SetIndexLabel(1,"downline");
SetIndexBuffer(2,upstopline);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,251);
SetIndexLabel(2,"upstopline");
SetIndexBuffer(3,downstopline);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,251);
SetIndexLabel(3,"downstopline");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
limit = Barss - counted_bars;
//----
for(int i =0; i <=limit; i++)
{
if((High[i+1] < High[i+2])&&(Low[i+1] > Low[i+2]))
{
upline[i] = High[i+1];
downline[i] = Low[i+1];
upstopline[i] = (High[i+1] + Low[i+1])/2;
//upstopline[i] = High[iHighest(NULL,0,MODE_HIGH,10,i)];
downstopline[i] = Low[iLowest(NULL,0,MODE_LOW,10,i)];
}
}
/*
for( i =0; i <=Barss; i++)
{
if(upline[i]==EMPTY_VALUE) upline[i] = upline[i+1];
if(downline[i]==EMPTY_VALUE) downline[i] = downline[i+1];
if(upstopline[i]==EMPTY_VALUE) upstopline[i] = upstopline[i+1];
if(downstopline[i]==EMPTY_VALUE) downstopline[i] = downstopline[i+1];
}
*/
//----
return(0);
}
//+------------------------------------------------------------------+
Comments