ZigZagFirst
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#property link "http://www.eazhijia.com"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//+------------------------------------------------------------------+
//| Custom Moving Average.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//|
//+------------------------------------------------------------------+
#property copyright "Ex4 to Mq4 decompiler v3.91"
#property link "http://www.eazhijia.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 White
//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//---- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(0,0.0);
ArraySetAsSeries(ExtMapBuffer,true);
ArraySetAsSeries(ExtMapBuffer2,true);
//---- indicator short name
IndicatorShortName("ZigZagFirstBar("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int shift, back,lasthighpos,lastlowpos;
double val,res;
double curlow,curhigh,lasthigh,lastlow;
for(shift=Bars-ExtDepth; shift>=0; shift--)
{
val=Low;
if(val==lastlow) val=0.0;
else
{
lastlow=val;
if((Low-val)>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer;
if((res!=0)&&(res>val)) continue;//ExtMapBuffer=0.0;
}
}
}
ExtMapBuffer=val;
//--- high
val=High;
if(val==lasthigh) val=0.0;
else
{
lasthigh=val;
if((val-High)>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer2;
if((res!=0)&&(res=0; shift--)
{
curlow=ExtMapBuffer;
curhigh=ExtMapBuffer2;
// if((curlow==0.0)||(curhigh==0.0)) continue;
//---
if(curhigh!=0)
{
if(lasthigh>0)
{
if(lasthigh0)
{
if(lastlow>curlow) ExtMapBuffer=0;
else ExtMapBuffer=0;
};//z
//---
if((curlow=0; shift--)
{
if(shift>=Bars-ExtDepth) ExtMapBuffer=0.0;
else
{
res=ExtMapBuffer2;
if(res!=0.0) ExtMapBuffer=res;
//if(res>0.0) ExtMapBuffer=res;
}
}
}
谢谢 {:1_179:} 谢谢 {:1_181:} 谢谢 {:1_181:} 顶下 支持下 顶下