Author: ��� ����� �. aka KimIV
i-GAP

This tool is designed for traders using the MetaTrader platform to identify specific price movements based on the "gap" between preceding and current price actions. Instead of relying on complex moving averages or momentum oscillators, this script focuses on a direct structural comparison of the market's open and close values.

Core Logic Overview

The indicator scans historical price data to detect instances where a significant price jump occurs from one candle to the next. It evaluates these "gaps" by comparing the closing price of a previous candle against the opening price of the current candle.

  • Buy Signals: The script identifies a potential upward momentum signal when the previous candle closed at a price significantly higher than the current candle's opening price (based on a user-defined gap size).
  • Sell Signals: Conversely, it identifies downward momentum when the previous candle closed at a price significantly lower than the current candle's opening price.

Key Functionalities

  • Customizable Sensitivity: Users can define the "SizeGAP," which determines how large of a price jump is required to trigger a visual signal on the chart. This allows you to filter out minor market fluctuations and focus only on larger, more impactful movements.
  • Historical Analysis: The script can be configured to look back over a specific number of candles (up to 10,000), allowing for a comprehensive review of past market behavior.
  • Dynamic Visual Spacing: To ensure the chart remains clean and readable, the tool automatically adjusts the distance at which the signal arrows appear. It recognizes different timeframe settings—ranging from very short minutes to multi-day charts—and shifts the arrows further away from the candles as the timeframe increases. This prevents the visual indicators from overlapping with price bars.

Visual Presentation

The logic translates these calculations into clear visual markers:

  • Light Blue Arrows appear below the candles to highlight potential buy opportunities.
  • Salmon-colored Arrows appear above the candles to highlight potential sell opportunities.
10 Views
0 Downloads
0 Favorites
i-GAP
//+------------------------------------------------------------------+
//|                                                        i-GAP.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 04.11.2005  Èíäèêàòîð ÃÝÏîâ                                      |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Salmon
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int SizeGAP     =5;      // Ðàçìåð ÃÝÏà
extern int NumberOfBars=10000;  // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
int ArrowInterval;
//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double SigBuy[];
double SigSell[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  void init() 
  {
   SetIndexBuffer(0, SigBuy);
   SetIndexStyle (0, DRAW_ARROW);
   SetIndexArrow (0, 233);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   //
   SetIndexBuffer(1, SigSell);
   SetIndexStyle (1, DRAW_ARROW);
   SetIndexArrow (1, 234);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   ArrowInterval=GetArrowInterval();
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  void start() 
  {
   double ms[2];
   int    LoopBegin, sh;
//----
   if (NumberOfBars==0) LoopBegin=Bars-1;
   else LoopBegin=NumberOfBars-1;
//----
     for(sh=LoopBegin; sh>=0; sh--) 
     {
      ms[0]=EMPTY_VALUE;
      ms[1]=EMPTY_VALUE;
      GetSignals(sh, ms);
      SigBuy[sh]=ms[0];
      SigSell[sh]=ms[1];
     }
  }
//+------------------------------------------------------------------+
//| Âîçâðàùàåò ñèãíàëû                                               |
//+------------------------------------------------------------------+
  void GetSignals(int nb, double& ms[]) 
  {
   double Cl1=Close[nb+1];
   double Op0=Open [nb];
//----
   if (Cl1>Op0+SizeGAP*Point) ms[0]=Low[nb]-ArrowInterval*Point;
   if (Cl1<Op0-SizeGAP*Point) ms[1]=High[nb]+ArrowInterval*Point;
  }
//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé              |
//+------------------------------------------------------------------+
  int GetArrowInterval() 
  {
   int p=Period();
     switch(p) 
     {
         case 1:     return(3);
         case 5:     return(5);
         case 15:    return(7);
         case 30:    return(10);
         case 60:    return(15);
         case 240:   return(20);
         case 1440:  return(50);
         case 10080: return(100);
         case 43200: return(200);
        }
     }
//+------------------------------------------------------------------+

Comments