Author: Copyright � 2006, free84
inout

This indicator is designed to analyze price action on a trading chart by identifying specific geometric relationships between consecutive candles. It focuses on how the highs and lows of the current candle interact with the previous ones, visually highlighting moments where the market expands or contracts in a distinct manner.

How the Logic Works

The script scans through historical price data to identify two primary types of price patterns:

1. The "Out" Pattern The logic identifies an "Out" pattern when the current candle's high is greater than the previous candle's high, and its low is simultaneously lower than the previous candle's low. Essentially, this detects a significant expansion where the current price action "wraps around" the previous candle, covering a wider vertical range. When this occurs, the script can display a visual mark on your chart (depending on your settings) to signal this breakout in volatility.

2. The "In" Pattern Conversely, the logic identifies an "In" pattern when the current candle's high is lower than the previous candle's high, and its low is higher than the previous candle's low. This represents a contraction or "inner" move, where the price action stays contained within the boundaries of the preceding candle. The indicator highlights these instances to show areas where the market may be consolidating or retreating inward.

Key Features and Visuals

  • Dynamic Charting: The indicator automatically detects your current timeframe (e.g., 1-minute, 1-hour, Daily) and processes the data accordingly.
  • Visual Markers: You can toggle the visibility of both "In" and "Out" patterns. These appear as histograms on your chart, allowing you to see at a glance where these structural changes occurred.
  • Real-Time Alerts: The script includes an alert system. When a new "In" or "Out" pattern is detected on the live chart, it can trigger a notification, ensuring you don't miss significant shifts in price movement.
  • Historical Analysis: Because the script loops through past bars, you can use it to back-test and identify how often these patterns occur during different market conditions (such as trending markets versus ranging markets).
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
inout
//+------------------------------------------------------------------+
//|                                                        inout.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, free84"
#property link      "free84@laposte.net"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern bool Show_Alert=true;
extern bool Display_Out=true;
extern bool Display_In=true;
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator line
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   double Range, AvgRange;
   int counter, setalert;
   static datetime prevtime=0;
   int shift;
   int shift1;
   int shift2;
   int shift3;
   string pattern, period;
   int setPattern=0;
   int alert=0;
   double O, O1, C, C1, L, L1, H, H1;
     if(prevtime==Time[0]) 
     {
      return(0);
     }
   prevtime=Time[0];
     switch(Period()) 
     {
         case 1:
            period="M1";
            break;
         case 5:
            period="M5";
            break;
         case 15:
            period="M15";
            break;
         case 30:
            period="M30";
            break;
         case 60:
            period="H1";
            break;
         case 240:
            period="H4";
            break;
         case 1440:
            period="D1";
            break;
         case 10080:
            period="W1";
            break;
         case 43200:
            period="MN";
            break;
        }
          for(int j=0; j < Bars; j++) 
        {
      }
        for(shift=0; shift < Bars; shift++) 
        {
         setalert=0;
         counter=shift;
         Range=0;
         AvgRange=0;
           for(counter=shift ;counter<=shift+9;counter++) 
           {
            AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
           }
         Range=AvgRange/9;
         shift1=shift ;
         shift2=shift + 1;
//----
         O=Open[shift1];
         O1=Open[shift2];
         H=High[shift1];
         H1=High[shift2];
         L=Low[shift1];
         L1=Low[shift2];
         C=Close[shift1];
         C1=Close[shift2];
         // Check for Out pattern
           if ((H>H1)&&(L<L1)) 
           {
            if (Display_Out==true)
              {
               val1[shift]=Low[shift]; val2[shift]=High[shift];
              }
              if (setalert==0 && Show_Alert==true) 
              {
               pattern="Out";
               setalert=1;
              }
           }
         // Check for In pattern
           if ((H<H1)&&(L>L1)) 
           {
              if (Display_In==true) 
              {
                 {
                  val1[shift]=High[shift]; val2[shift]=Low[shift];
                 }
                 if (setalert==0 && Show_Alert==true) 
                 {
                  pattern="In";
                  setalert=1;
                 }
              }
           }
        } // End of for loop
   //----
      return(0);
     }
//+------------------------------------------------------------------+

Comments