//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #property indicator_chart_window extern bool DisplayInsideBars = true; extern bool DisplaySidewaysPattern = true; extern int display_higher_tf = 3; datetime currentbar[10]; int TFs[10]={ 0, 1, 5, 15, 30, 60, 240, 1440, 10080, 43200 }; string TFns[10]={ "", "M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN" }; int dgt=1; int dgt2=0; double PRL, PRH; double cpr[10][5]; // inside bar double cps[10][5]; // sideways pattern string RRcomm[10]; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { objdel(); if (Digits==3 || Digits==5) { dgt=10; dgt2=1; } ArrayInitialize(cpr,0); ArrayInitialize(currentbar,0); for(int i=1;i<10;i++) { RRcomm[i]=""; } return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { objdel(); return(0); } int tf2nr(int tfc) { switch(tfc) { case 1: return(1); case 5: return(2); case 15: return(3); case 30: return(4); case 60: return(5); case 240: return(6); case 1440: return(7); case 10080: return(8); case 43200: return(9); } return(0); } void ibld(string objn, datetime t1, double p1, datetime t2, double p2, color linecolor, int thickness) { int line_style = 2; //color linecolor = Silver; ObjectCreate(objn, OBJ_TREND, 0, t1, p1, t2, p2); ObjectSet(objn, OBJPROP_STYLE, line_style); ObjectSet(objn, OBJPROP_WIDTH, thickness); ObjectSet(objn, OBJPROP_COLOR, linecolor); ObjectSet(objn, OBJPROP_BACK, TRUE); } void ibbd(string objn, datetime t1, double p1, datetime t2, double p2, color boxcolor) { //color boxcolor1 = C'0x00,0x00,0x4F'; //color boxcolor2 = MidnightBlue; //color boxcolor3 = Red; ObjectCreate(objn, OBJ_RECTANGLE, 0, t1, p1, t2, p2); ObjectSet(objn, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(objn, OBJPROP_COLOR, boxcolor); ObjectSet(objn, OBJPROP_BACK, TRUE); } int ChkRanging(string ap, int tfc, int tfnr) { // RANGING, inside bar, congestion cpr[tfnr][1]=0; // start cpr[tfnr][2]=0; // min, low cpr[tfnr][3]=0; // max, high int prs=0; // potential range start double h0=0, l0=0, h1=0, l1=0, h2, l2, o1, c1, rh=0, rl=0; datetime t0, t1, t2; for (int rd=100;rd>1;rd--) { h0=iHigh(ap, tfc, rd); l0=iLow(ap, tfc, rd); h1=iHigh(ap, tfc, rd-1); l1=iLow(ap, tfc, rd-1); if (h0>h1 && l0l2) && (h2>h1) && (l2h1) && (l2l2) { rl=l2; } } */ o1=iOpen(ap, tfc, ssh); c1=iClose(ap, tfc, ssh); if ((o1rl) || ((c1rl))) // nyitás vagy zárás a sávon belül { rc++; // sáv szélesítése - nem kell // if (rhl1) { rl=l1; } } else { // sávon kívül nyitott vagy zárt, nincs ranging prs=0; rh=0; rl=0; inrg=false; } ssh--; if ((ssh<1) && (inrg)) { rd=0; } if (ssh<1) { inrg=false; } } } } string on1=TFns[tfnr]; ObjectDelete("IB-box-"+on1); ObjectDelete("IB-lineH-"+on1); ObjectDelete("IB-lineL-"+on1); if (rh>0) { cpr[tfnr][1]=prs; // start cpr[tfnr][2]=rl; // min, low cpr[tfnr][3]=rh; // max, high if (DisplayInsideBars) { t0=iTime(ap, tfc, 0); t1=iTime(ap, tfc, prs-1); t2=iTime(ap, tfc, prs); ibbd("IB-box-"+on1, t1, rh, t2, rl, MidnightBlue); ibld("IB-lineH-"+on1, t2, rh, t0, rh, Silver, 1); ibld("IB-lineL-"+on1, t2, rl, t0, rl, Silver, 1); } } } int ChkSidewaysPattern(string ap, int tfc, int tfnr) { // hiányzik: újabb előzőn belül // congestion - sideways pattern cps[tfnr][1]=0; // start cps[tfnr][2]=0; // min, low cps[tfnr][3]=0; // max, high int prs=0; // potential range start int swpc=0; // sideways pattern count double h0=0, l0=0, h1=0, l1=0, h2, l2, o1, c1, rh=0, rl=0; datetime t0, t1, t2; for (int rd=100;rd>3;rd--) { h0=iHigh(ap, tfc, rd); l0=iLow(ap, tfc, rd); o1=iOpen(ap, tfc, rd-1); c1=iClose(ap, tfc, rd-1); if ((o1l0) || (c1l0)) // open or close within prev.bar { //Print(ap, "/",tfc," ST IB: RD: ",rd); prs=rd; rh=h0; rl=l0; bool inrg=true; int ssh=rd-2; int rs=0, re=0, rc=2; while (inrg) { //Print(ap, "/",tfc," CC IB: RD: ",rd, " SSH: ", ssh); o1=iOpen(ap, tfc, ssh); c1=iClose(ap, tfc, ssh); if ((o1l0) || ((c1l0))) // nyitás vagy zárás a sávon belül { rc++; } else { // sávon kívül nyitott vagy zárt, nincs ranging prs=0; rh=0; rl=0; inrg=false; } ssh--; if ((ssh<1) && (inrg)) { rd=0; } if (ssh<1) { inrg=false; } } } } if (rc<4) { prs=0; rh=0; rl=0; } string on1=TFns[tfnr]; ObjectDelete("SW-box-"+on1); ObjectDelete("SW-lineH-"+on1); ObjectDelete("SW-lineL-"+on1); if (rh>0) { cps[tfnr][1]=prs; // start cps[tfnr][2]=rl; // min, low cps[tfnr][3]=rh; // max, high if (DisplaySidewaysPattern) { t0=iTime(ap, tfc, 0); t1=iTime(ap, tfc, prs-1); t2=iTime(ap, tfc, prs); ibbd("SW-box-"+on1, t1, rh, t2, rl, Red); ibld("SW-lineH-"+on1, t2, rh, t0, rh, Silver, 1); ibld("SW-lineL-"+on1, t2, rl, t0, rl, Silver, 1); } } } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { string ap=Symbol(); int tfc=Period(); int chart_tfnr=tf2nr(Period()); //---------------------------------------------------------------- for (int x=chart_tfnr;x0) { RRcomm[x]=TFns[x]+" INSIDE BAR ("+DoubleToStr(cpr[x][1],0)+") L: "+DoubleToStr(cpr[x][2],Digits)+" H: "+DoubleToStr(cpr[x][3],Digits)+" DIFF: "+DoubleToStr((cpr[x][3]-cpr[x][2])/Point/dgt,dgt2)+"\n"; } ChkSidewaysPattern(ap, TFs[x], x); if (cps[x][2]>0) { RRcomm[x]=RRcomm[x]+TFns[x]+" SIDEWAYS PATTERN ("+DoubleToStr(cps[x][1],0)+") L: "+DoubleToStr(cps[x][2],Digits)+" H: "+DoubleToStr(cps[x][3],Digits)+" DIFF: "+DoubleToStr((cps[x][3]-cps[x][2])/Point/dgt,dgt2)+"\n"; } // ------------------------------------------------------------------- } } } string comm=""; for(int i=1;i<10;i++) { if (RRcomm[i]!="") { comm=comm+RRcomm[i]; } } Comment(comm); return(0); } //+------------------------------------------------------------------+ void objdel() { for(int i=1;i<10;i++) { ObjectDelete("IB-box-"+TFns[i]); ObjectDelete("IB-lineH-"+TFns[i]); ObjectDelete("IB-lineL-"+TFns[i]); ObjectDelete("SW-box-"+TFns[i]); ObjectDelete("SW-lineH-"+TFns[i]); ObjectDelete("SW-lineL-"+TFns[i]); } return(0); }