#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
double BufferHigh[];
double BufferLow[];
// Inputs
input bool UseEqualHL = false;
input bool MarkHL = true;
input color HLColor = clrGray;
input bool MarkInternalStructure = false;
input color PivotHighColor = clrRed;
input color PivotLowColor = clrGreen;
input bool MarkBoSChoCH = true;
input color BullColor = clrGreen;
input color BearColor = clrRed;
input bool MarkPreviousIDM = true;
input bool MarkLiveIDM = true;
input color IDMColor = clrGray;
input bool ShowSweepingLines = true;
input color SweepLineColor = clrGray;
// Variables
bool mnUp = false;
bool mnDn = false;
double mnStrc = 0;
double H = 0, L = 0;
double lastH = 0, lastL = 0;
double lastHH = 0, lastLL = 0;
int Hbar = 0, Lbar = 0;
int lastHbar = 0, lastLbar = 0;
int lastHHbar = 0, lastLLbar = 0;
bool isBosUp = false;
bool isBosDn = false;
bool isCocUp = true;
bool isCocDn = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0, BufferHigh);
SetIndexBuffer(1, BufferLow);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, Red);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1, Green);
ArraySetAsSeries(BufferHigh, true);
ArraySetAsSeries(BufferLow, true);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 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[])
{
int limit = prev_calculated;
if (limit < 0) return(-1);
if (limit == 0) limit = rates_total - 1;
for (int i = limit; i >= 0; i--)
{
// Update High/Low variables
if (high[i] > H || i == rates_total - 1)
{
H = high[i];
Hbar = i;
}
if (low[i] < L || i == rates_total - 1)
{
L = low[i];
Lbar = i;
}
// Mark High/Low
if (MarkHL)
{
BufferHigh[i] = H;
BufferLow[i] = L;
}
// Structure mapping logic
if (high[i] > lastH)
{
if (low[i] < lastL)
{
isBosUp = false;
}
lastH = high[i];
lastHbar = i;
}
if (low[i] < lastL)
{
if (high[i] > lastH)
{
isBosDn = false;
}
lastL = low[i];
lastLbar = i;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+