Gann_SQ9_A

//+------------------------------------------------------------------+
//|
Gann_S9.mq4 |
//|
idea Pasha |
//|
ZigZag_new_nen4.mq4 |
//|
//|

nen |
DimDimych |

//|
http://open-forex.org |
//+------------------------------------------------------------------+
#property copyright "DimDimych"
#property link
"dm34@mail.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 AliceBlue
#property indicator_width1 0
#property indicator_style1 2
//---extern double angle_up
extern double angle_dn
extern int
Width
extern int
Style
extern int
kol_lev
extern color
ResistanceColor
extern color
SupportColor
extern color
Level_0
extern bool
lev_V
extern color
Level_V
extern int
Complect
color öâåò_óðîâíÿ;

=
=
=
=
=
=
=
=
=
=
=

22.5;
22.5;
0;
2;
8;
Tomato;
DodgerBlue;
LightSteelBlue;
true;
LightSteelBlue;
0;

extern int ExtDepth=21;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//---//---double ZigZagBuffer[];
int timeFirstBar=0;
int flag;
bool work=true;
double vel_prev;
//+------------------------------------------------------------------+
//| ZigZag initialization function
|
//+------------------------------------------------------------------+
int init()
Page 1

supr2_bar. back.ZigZag3. int metka=0.lastlow.0).curhigh.äî ïåðâîãî ïåðåëîìà ZZ. //---."+ExtDeviation+".DRAW_SECTION. Comment("").lasthigh.TempBuffer[1]. double val. =1 .time4.res. // =0 .ïðîâåðêà íà âîçìîæíûå îøèáêè if (counted_bars<0)return(-1). =2 Page 2 . //----+ Ââåäåíèå öåëûõ ïåðåìåííûõ äëÿ ïåðåñ÷¸òà èíäèêàòîðà òîëüêî íà íåïîäñ÷èòàííûõ áàðàõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ int MaxBar. SetIndexStyle(0.supr3_bar. shift.ZigZag4.0. double curlow.counted_bars=IndicatorCounted(). } //+------------------------------------------------------------------+ //| deinit | //+------------------------------------------------------------------+ int deinit() { //---ObjDel(). //----+ Ââåäåíèå öåëûõ ïåðåìåííûõ ïàìÿòè äëÿ ïåðåñ÷¸òà èíäèêàòîðà òîëüêî íà íåïîäñ÷èòàííûõ áàðàõ static int time2.ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí if (counted_bars>0) counted_bars--. //----+ Ââåäåíèå ïåðåìåííûõ ñ ïëàâàþùåé òî÷êîé äëÿ ïåðåñ÷¸òà èíäèêàòîðà òîëüêî íà íåïîäñ÷èòàííûõ áàðàõ static double ZigZag2. //----+ Ââåäåíèå ïåðåìåííûõ int index.supr4_bar. //---. SetIndexEmptyValue(0.limit.Gann_SQ9_A { //---SetIndexBuffer(0.ZigZagBuffer).èùåì ìåòêè ìàêñèìóìîâ. } //+------------------------------------------------------------------+ //| ZigZag iteration function | //+------------------------------------------------------------------+ int start() { //----+ ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ êîððåêòíîãî ðàñ÷¸òà èíäèêàòîðà if (Bars-1<ExtDepth)return(0).lastlowpos."+ExtBackstep+")"). //---return(0). IndicatorShortName("ZigZag("+ExtDepth+".time3. //---return(0).2).lasthighpos.

èíèöèàëèçàöèÿ íóëÿ if (limit>=MaxBar || timeFirstBar!=Time[Bars-1]) { timeFirstBar=Time[Bars-1]. //----+-------------------------------------------------+ //----+ íà÷àëî ïåðâîãî áîëüøîãî öèêëà for(shift=limit.limit+ExtBackstep+1). supr4_bar=iBarShift(NULL.0. //---limit=supr3_bar.îïðåäåëåíèå íîìåðà ñòàðòîâîãî áàðà â öèêëå. limit=MaxBar. if ((supr2_bar<0)||(supr3_bar<0)||(supr4_bar<0)) { limit=MaxBar.shift)].ExtDepth. } else { //---supr2_bar=iBarShift(NULL. íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïîëûé ïåðåñ÷¸ò âñåõ áàðîâ MaxBar=Bars-ExtDepth.MODE_LOW.Bars). íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåäèòüñÿ ïåðåñ÷¸ò íîâûõ áàðîâ if (counted_bars==0 || Bars-counted_bars>2) { limit=MaxBar. shift--) { //--. } } //---. else { lastlow=val. //---. else ArrayResize(TempBuffer. } //---//---.0.time3.time4. Page 3 .0.TRUE). //---.TRUE).0. shift>=0. supr3_bar=iBarShift(NULL.TRUE).èçìåíåíèå ðàçìåðà âðåìåííîãî áóôåðà if (limit==MaxBar) ArrayResize(TempBuffer.îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà.Low val=Low[Lowest(NULL.0. if(val==lastlow) val=0.Gann_SQ9_A èùåì ìåòêè ìèíèìóìîâ.time2.

if((res!=0)&&(res<val)) TempBuffer[shift+back]=0. else { for(back=1.0. back<=ExtBackstep. //if (ExtLabel==1) la[shift]=val.0. back<=ExtBackstep. back++) { res=TempBuffer[shift+back]. if(val==lasthigh) val=0. else { lasthigh=val. else { for(back=1. if((res!=0)&&(res>val)) ZigZagBuffer[shift+back]=0. //if (ExtLabel==1) ha[shift]=val.0.0. } //----+ êîíåö ïåðâîãî áîëüøîãî öèêëà // final cutting lasthigh=-1. //--. if((val-High[shift])>(ExtDeviation*Point)) val=0. back++) { res=ZigZagBuffer[shift+back].0.Gann_SQ9_A if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0. lastlowpos= -1.shift)].ExtDepth. } else ZigZagBuffer[shift]=0. } } } if (Low[shift]==val) { ZigZagBuffer[shift]=val.0. } } } if (High[shift]==val) { TempBuffer[shift]=val. lasthighpos=-1. //----+-------------------------------------------------+ Page 4 .MODE_HIGH. lastlow= -1. } else TempBuffer[shift]=0.High val=High[Highest(NULL.0.

lasthighpos=shift. } lastlow=-1. shift>=0. if((curlow==0)&&(curhigh==0)) continue. } lasthigh=-1. } //---if(curlow!=0) { if(lastlow>0) { if(lastlow>curlow) ZigZagBuffer[lastlowpos]=0. lastlowpos=shift. } //--if((curlow<lastlow)||(lastlow<0)) { lastlow=curlow. Page 5 . else TempBuffer[shift]=0. shift>=0. } //--if(lasthigh<curhigh || lasthigh<0) { lasthigh=curhigh. shift--) { res=TempBuffer[shift]. } } //----+ êîíåö âòîðîãî áîëüøîãî öèêëà //----+-------------------------------------------------+ //----+ íà÷àëî òðåòüåãî öèêëà for(shift=limit. shift--) { curlow=ZigZagBuffer[shift]. curhigh=TempBuffer[shift].Gann_SQ9_A //----+ íà÷àëî âòîðîãî áîëüøîãî öèêëà for(shift=limit. else ZigZagBuffer[shift]=0. //--if(curhigh!=0) { if(lasthigh>0) { if(lasthigh<curhigh) TempBuffer[lasthighpos]=0.

for(int qqq=supr4_bar-1. } //----+ êîíåö òðåòüåãî öèêëà // Ïðîâåðêà ïåðâîãî ëó÷à int i=0. } if (i==2 && res>0 && ZigZagBuffer[shift]==High[shift]) { if (ZigZagBuffer[shift]>=ZigZagBuffer[j]) ZigZagBuffer[j]=0. if (limit==MaxBar)supr4_bar=MaxBar. bar--) { if (ZigZagBuffer[bar]!=0) Page 6 . } } } //+--. vel3. ZigZagBuffer[supr3_bar]=ZigZag3.0) ZigZagBuffer[shift]=res. for (shift=0.èñïðàâëåíèå âîçíèêàþùèõ ãîðáîâ double vel1. for(int ggg=supr3_bar-1. qqq>supr3_bar.Âîññòàíîâëåíèå çíà÷åíèé èíäèêàòîðíîãî áóôôåðà. for(int bar=supr4_bar. bar>=0. bar2. i=0. bar4. ZigZagBuffer[supr4_bar]=ZigZag4. res=ZigZagBuffer[shift]. else ZigZagBuffer[shift]=0.shift++) { if (ZigZagBuffer[shift]>0) { i++. int count. j=0. if (i==1 && ZigZagBuffer[shift]==High[shift]) { j=shift. res=0. shift=0. vel4. res=0. qqq--)ZigZagBuffer[qqq]=0.i<3. ggg>supr2_bar. ggg--)ZigZagBuffer[ggg]=0. bar3. int bar1. } //+---+============================================+ //+--.Gann_SQ9_A if(res!=0. vel2. êîòîðûå ìîãëè áûòü óòåðÿíû if (limit<MaxBar) { ZigZagBuffer[supr2_bar]=ZigZag2.j=0.

ZigZag3=vel3.vel1.} if ((vel2==vel1)&&(vel1!=0 )){ZigZagBuffer[bar1]=0. for(i = 1. time3=Time[bar3]. i++ ) { PlotLine("_lev "+bar1+"_"+Complect+"_"+i. time4=Time[bar4].vel1. i++ ) { PlotLine("_lev "+bar1+"_"+Complect+"_"+i.angle_dn*i.çàïîìèíàíèå âðåìåíè òð¸õ ïîñëåäíèõ ïåðåãèáîâ Çèãçàãà è çíà÷åíèé èíäèêàòîðà â ýòèõ òî÷êàõ time2=Time[bar2]. } } PlotLineM("_lev "+bar1+"_"+Complect+"_".vel1.bar1. vel2=vel1. } //+--if(Low[bar2]==vel2) { flag=1. for(i = 1. } } else { flag=-1.0.0. if ((vel3<vel2)&&(vel2<vel1)){ZigZagBuffer[bar2]=0.bar=bar3+1. ZigZag2=vel2.bar=bar3+1. i <= kol_lev. flag). i <= kol_lev.bar2=bar1. if (count<3)continue.} } } //+--. vel1=ZigZagBuffer[bar]. ObjDel().bar1. for(i = 1.bar1=bar.bar3=bar2. i++ ) Page 7 . flag).bar1.bar1. if(bar1>=2) { if(Low[bar1]==vel1) { flag=1.bar4=bar3.flag).angle_up*i.bar1. vel4=vel3.} if ((vel3>vel2)&&(vel2>vel1)){ZigZagBuffer[bar2]=0.bar1. i <= kol_lev.0. ZigZag4=vel4.bar=bar3+1.Gann_SQ9_A { count++. vel3=vel2.

//+--if(Low[bar3]==vel3) { flag=1. i <= kol_lev. } } Page 8 flag).angle_dn*i.Gann_SQ9_A { PlotLine("_lev "+bar2+"_"+Complect+"_"+i.bar3. for(i = 1.bar4. //+--if(Low[bar4]==vel4) { flag=1. i <= kol_lev.bar1.vel2.bar2.angle_up*i.vel4.bar3.bar1. flag).vel2. flag). i <= kol_lev.angle_dn*i.bar4. i++ ) { PlotLine("_lev "+bar4+"_"+Complect+"_"+i. i++ ) { PlotLine("_lev "+bar4+"_"+Complect+"_"+i.1. } } PlotLineM("_lev "+bar3+"_"+Complect+"_".1.angle_dn*i. i <= kol_lev. i++ ) { PlotLine("_lev "+bar3+"_"+Complect+"_"+i. for(i = 1.bar2.bar3. } } else { flag=-1.bar2.1. for(i = 1.vel3.bar2.1.bar3. i++ ) { PlotLine("_lev "+bar2+"_"+Complect+"_"+i.vel4.angle_up*i. .vel3. } } else { flag=-1.1.bar2.flag).bar1. } } else { flag=-1.vel2. for(i = 1.flag). flag).1. i <= kol_lev. } } PlotLineM("_lev "+bar2+"_"+Complect+"_".bar2. flag).vel3.1. i++ ) { PlotLine("_lev "+bar3+"_"+Complect+"_"+i.bar3.1. flag).angle_up*i. for(i = 1.

ObjectCreate(name+" V". ObjectCreate(name+" 0". ObjectSet(name+" V".OBJ_TREND.int lev0.int âåðõ_âíèç) { int D2.nBar.Digits). Page 9 . else if(âåðõ_âíèç==-1) P1=Price1+4*Point.OBJPROP_BACK. ObjectSetText(name+" 0txt".0).points.Time[Date1].bar3.Time[Date1].D2.vel4. double P1.int âåðõ_âíèç) { double level.Level_0).int Date2. ObjectDelete(name+" 0txt"). ObjectSet(name+" 0".int Date1.0.Price1).0. //---+ if(lev_V) { ObjectDelete(name+" V").OBJPROP_WIDTH.double Price1. ObjectCreate(name+" 0txt". "Tahoma". else D2=Time[0]+50*Period()*60. 0. 8.2).Gann_SQ9_A PlotLineM("_lev "+bar4+"_"+Complect+"_".OBJPROP_STYLE. ObjectSet(name+" V". //---+ if(âåðõ_âíèç==1) P1=Price1-2*Point.OBJPROP_RAY. ObjectSet(name+" V". } //---+ } //---+ +---------------------------------------------------------------------+ void PlotLine(string name.int Date2. ObjectSet(name+" V".1).OBJPROP_STYLE.OBJPROP_WIDTH. ObjectSet(name+" 0". if(lev0==1) D2=Time[Date2].OBJPROP_COLOR.OBJ_VLINE. P1).double Price1. OBJ_TEXT.int lev0. int D2. return(0).0). ObjectSet(name+" 0".1.int Date1.Price1.OBJPROP_COLOR.Level_0). DoubleToStr(Price1. ObjectSet(name+" 0". Time[Date1].Level_V).bar4. ObjectDelete(name+" 0").double gr.true).false).flag). } //---+ +---------------------------------------------------------------------+ void PlotLineM(string name.0).

//--} //--------------------------------------------------------void ObjDel() { Page 10 .Gann_SQ9_A if(Digits==5 || Digits==3) points=Point*10. ObjectCreate(name.D2.0. ObjectSet(name. else points=Point. ObjectDelete(name).Style). if(âåðõ_âíèç==1) { level=MathSqrt(Price1/points)+gr/180. } ObjectSetText(name+" txt".2)*points. Time[nBar]. } else if(âåðõ_âíèç==-1) { level=MathSqrt(Price1/points)-gr/180.öâåò_óðîâíÿ). level). 0. level=MathPow(level. "Tahoma". level=MathPow(level. } if(lev0==1) D2=Time[Date2].Width).OBJPROP_RAY. 0. 8.false).OBJPROP_STYLE.level.Digits). ObjectSet(name. OBJ_TEXT. level). OBJ_TEXT. DoubleToStr(gr.level).Time[Date1]. else D2=Time[0]+50*Period()*60. öâåò_óðîâíÿ=ResistanceColor.OBJPROP_COLOR. } else { ObjectCreate(name+" txt". ObjectSet(name. Time[0]+8*Period()*60. //--ObjectDelete(name+" txt").OBJ_TREND. if(lev0==1) { nBar=Date1-8. ObjectCreate(name+" txt".1)+"° "+DoubleToStr(level. ObjectSet(name.OBJPROP_WIDTH. öâåò_óðîâíÿ=SupportColor.2)*points.öâåò_óðîâíÿ).

} } } Page 11 . i >= 0. "_". i -.Gann_SQ9_A for ( int i = ObjectsTotal() .) { if ( StringFind( ObjectName(i). 0 ) == 0 ) { ObjectDelete( ObjectName(i) ).1.

Sign up to vote on this title
UsefulNot useful