
//+------------------------------------------------------------------+
//| GapsShow.mq5 |
//| Copyright 2022, AM2 |
//| https://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, AM2"
#property link "https://www.forexsystems.biz"
#property version "1.00"
#property indicator_chart_window
#property indicator_plots 0
input int bars=22;
input color cl=Red;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
ObjectsDeleteAll(0,0,OBJ_HLINE);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectsDeleteAll(0,0,OBJ_HLINE);
}
//+------------------------------------------------------------------+
//| Горизонтальная линия |
//+------------------------------------------------------------------+
void PutHLine(string name,double p,color clr=Red)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_HLINE,0,0,p);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектов
ObjectSetInteger(0,name,OBJPROP_HIDDEN,0);
//--- включим (true) или отключим (false) режим перемещения линии мышью
//--- при создании графического объекта функцией ObjectCreate, по умолчанию объект
//--- нельзя выделить и перемещать. Внутри же этого метода параметр selection
//--- по умолчанию равен true, что позволяет выделять и перемещать этот объект
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,1);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
for(int i=0; i<bars; i++)
{
if(NormalizeDouble(iOpen(NULL,0,i),4)!=NormalizeDouble(iClose(NULL,0,i+1),4))
PutHLine((string)iOpen(NULL,0,i+1)+" "+(string)iTime(NULL,0,i+1),iOpen(NULL,0,i+1),cl);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Индикатор показывает все не закрытые разрывы цены
AM2