//±-----------------------------------------------------------------+
//| ZigZag.mq4 |
//| Copyright 2006-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//±-----------------------------------------------------------------+
#property copyright “2006-2014, MetaQuotes Software Corp.”
#property link “http://www.mql4.com”
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
//---- indicator parameters
input int InpDepth=12; // Depth
input int InpDeviation=5; // Deviation
input int InpBackstep=3; // Backstep
//---- indicator buffers
double ExtZigzagBuffer[];
double ExtHighBuffer[];
double ExtLowBuffer[];
//— globals
int ExtLevel=3; // recounting’s depth of extremums
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int OnInit()
{
if(InpBackstep>=InpDepth)
{
Print(“Backstep cannot be greater or equal to Depth”);
return(INIT_FAILED);
}
//— 2 additional buffers
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_SECTION);
SetIndexStyle(1,DRAW_SECTION);
SetIndexStyle(2,DRAW_SECTION);
//---- indicator buffers
SetIndexBuffer(0,ExtZigzagBuffer);
SetIndexBuffer(1,ExtHighBuffer);
SetIndexBuffer(2,ExtLowBuffer);
SetIndexEmptyValue(0,0.0);
//---- indicator short name
IndicatorShortName(“ZigZag(”+string(InpDepth)+","+string(I