//+------------------------------------------------------------------+ //| JJN-Fibo.mq4 | //| Copyright © 2010, JJ Newark | //| http://jjnewark.atw.hu | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, JJ Newark" #property link "http://jjnewark.atw.hu" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 Chocolate #property indicator_color2 DarkSlateGray #property indicator_color3 DarkSlateGray #property indicator_color4 Chocolate #property indicator_color5 DarkSlateGray #property indicator_color6 Chocolate #property indicator_color7 DarkSlateGray #property indicator_width1 2 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 2 #property indicator_width7 1 //---- indicator buffers double Fib0[]; double Fib1[]; double Fib2[]; double Fib3[]; double Fib4[]; double Fib5[]; double Fib6[]; double H,L,W; //int UniqueId; extern int ProcessedUnits = 1; extern color TextColor = Black; extern string Help_For_BasisTF = "M:43200;W:10080;D1:1440;H4:240;H1:60"; extern int BasisTF = PERIOD_D1; extern string Help_for_DisplayDecimals = "Used only: 4,5!"; extern int DisplayDecimals = 4; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Fib0); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexBuffer(1,Fib1); SetIndexStyle(2,DRAW_LINE,STYLE_DOT); SetIndexBuffer(2,Fib2); SetIndexStyle(3,DRAW_LINE,STYLE_DOT); SetIndexBuffer(3,Fib3); SetIndexStyle(4,DRAW_LINE,STYLE_DOT); SetIndexBuffer(4,Fib4); SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,Fib5); SetIndexStyle(6,DRAW_LINE,STYLE_DOT); SetIndexBuffer(6,Fib6); SetIndexLabel(0,"Fib0"); SetIndexLabel(1,"Fib1"); SetIndexLabel(2,"Fib2"); SetIndexLabel(3,"Fib3"); SetIndexLabel(4,"Fib4"); SetIndexLabel(5,"Fib5"); SetIndexLabel(6,"Fib6"); IndicatorShortName("JJN-Fibo"); //MathSrand(TimeLocal()); //UniqueId=MathRand(); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("FibLevel0"); ObjectDelete("FibLevel1"); ObjectDelete("FibLevel2"); ObjectDelete("FibLevel3"); ObjectDelete("FibLevel4"); ObjectDelete("FibLevel5"); ObjectDelete("FibLevel6"); Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- datetime starttime[]; int shift_open[]; int unitbars[]; ArrayResize(starttime,ProcessedUnits); ArrayResize(shift_open,ProcessedUnits); ArrayResize(unitbars,ProcessedUnits); for(int i=0; i=0; j--) { for(i=unitbars[j]-1; i>=0; i--) { int shift_close=iBarShift(NULL,0,Time[summabars-k]); int countbars=shift_open[j]-shift_close+1; H=High[iHighest(NULL,0,MODE_HIGH,countbars,summabars-k)]; L=Low[iLowest(NULL,0,MODE_LOW,countbars,summabars-k)]; W=H-L; Fib0[summabars-k]=H; Fib5[summabars-k]=L; Fib1[summabars-k]=H-(W*0.236); Fib2[summabars-k]=H-(W*0.382); Fib3[summabars-k]=H-(W*0.50); Fib4[summabars-k]=H-(W*0.618); Fib6[summabars-k]=H-(W*0.764); k++; } } // ObjectDelete("FibLevel0"); ObjectDelete("FibLevel1"); ObjectDelete("FibLevel2"); ObjectDelete("FibLevel3"); ObjectDelete("FibLevel4"); ObjectDelete("FibLevel5"); ObjectDelete("FibLevel6"); int Is_JPY=StringFind(Symbol(),"JPY",0); if(Is_JPY==-1) { int DisplayDec=DisplayDecimals; } else if(Is_JPY!=-1) { DisplayDec=DisplayDecimals-2; } if(iHighest(NULL,0,MODE_HIGH,unitbars[0],0)> JJN-Fibo || http://jjnewark.atw.hu"); //---- //---- return(0); } //+------------------------------------------------------------------+