//000cot120 #property indicator_level1 0 #property indicator_separate_window #property indicator_buffers 9 #property indicator_plots 3 #property indicator_label1 "a" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed //non commartial long #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_type2 DRAW_LINE #property indicator_color2 clrDeepSkyBlue//commartial jitumu #property indicator_style2 STYLE_SOLID//DASH #property indicator_width2 5 #property indicator_type3 DRAW_LINE #property indicator_color3 clrLimeGreen////non commartial long- #property indicator_style3 STYLE_SOLID #property indicator_width3 2 #property indicator_type4 DRAW_LINE #property indicator_color4 clrSlateGray #property indicator_style4 STYLE_SOLID #property indicator_width4 5 #property indicator_type5 DRAW_LINE #property indicator_color5 clrNONE//Red amot #property indicator_style5 STYLE_SOLID #property indicator_width5 2 #property indicator_type6 DRAW_LINE #property indicator_color6 clrWhite #property indicator_style6 STYLE_DASH #property indicator_width6 1 #property indicator_type7 DRAW_LINE #property indicator_color7 clrAqua #property indicator_style7 STYLE_SOLID #property indicator_width7 1 #property indicator_type8 DRAW_LINE #property indicator_color8 clrYellow// #property indicator_style8 STYLE_SOLID #property indicator_width8 5 #property indicator_type9 DRAW_LINE #property indicator_color9 clrYellow// #property indicator_style9 STYLE_SOLID #property indicator_width9 5 //input datetime InpDateStart=D'2016.01.01 00:00'; //---- indicator parameters input string Code="xxxxxx"; input int period_0=156; // Period of COT index and WILLCO index input int period_1=52; // Period of OI index input int period_2=6; // Rate of change for Movement index and Spread movement index //input string InpSymbolName=NULL; // currency pair //input ENUM_TIMEFRAMES InpSymbolPeriod=0; //+------------------------------------------------------------------+ //| Indicators | //+------------------------------------------------------------------+ enum id { COT, // COT index WILLCO, // WILLCO index Spread_move,// Spread movement index Movement, // Movement index Open_interest, // Open interest Net, // Positions net Long, // Positions long Short, // Positions short Pct_net, // Percent of OI for positions net Pct_long, // Percent of OI for positions long Pct_short, // Percent of OI for positions short commercial }; input id Indicator=commercial; input bool OI_index=true; // OI index input bool Large=true; // Noncommercial input bool Comm=true; // Commercial input bool Specs=true; // Nonreportable input bool Inverted=false; // Inverted chart input bool Histogram=false; //put string InpFileName="RSI.csv"; // file name bool work=true; double zi=-1; double l0=100; double l1=50; double Buffer0[],Buffer1[],Buffer2[],Buffer3[],Buffer4[],Buffer5[],Buffer6[],E1[],E2[],E3[],az; int b,p0,p1,p2; double OIdd[],L1dd[],L2dd[],L3dd[],S1dd[],S2dd[],S3dd[],C1dd[],C2dd[],C3dd[],bdd,p0dd,p1dd,p2dd; int S3[],OI[],L1[],L2[],L3[],S1[],S2[],C1[],C2[],C3[]; datetime DT[]; string c,n,w; string c1; char j=2; uint x; double Buffer7[]; double BuffS1[]; double BuffS2[]; int size1; //int def_size; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(_Periodk; i--) { h=(string)i+".txt"; if(FileIsExist(h)) { files[d]=h; d++; } else if(d>0) break; } if(d==0) { Alert("There are not files year.txt in the folder Files/MQL5!"); GlobalVariableSet(n,0); work=false; return(rates_total); } string column1="\"CFTC Contract Market Code\""; string column2="\"As of Date in Form YYYY-MM-DD\""; string column3="\"Open Interest (All)\""; string column4="\"Noncommercial Positions-Long (All)\""; string column5="\"Noncommercial Positions-Short (All)\""; string column6="\"Commercial Positions-Long (All)\""; string column7="\"Commercial Positions-Short (All)\""; string column8="\"Nonreportable Positions-Long (All)\""; string column9="\"Nonreportable Positions-Short (All)\""; for(z=0; z20) continue; //610 if(f<=18) { if(text[i]==column1) n1=i;//karamu hidari ichiue if(text[i]==column2) n2=i; if(text[i]==column3) n3=i;//3karamu 8 if(text[i]==column4) n4=i; if(text[i]==column5) n5=i; if(text[i]==column6) n6=i; if(text[i]==column7) n7=i; if(text[i]==column8) n8=i; if(text[i]==column9) n9=i; if(f==18) { if((n1==0)||(n2==0)||(n3==0)||(n4==0) ||(n5==0)||(n6==0)||(n7==0)||(n8==0)||(n9==0)) { v=" "; if(n1==0) v+="\n"+column1; if(n2==0) v+="\n"+column2; if(n3==0) v+="\n"+column3; if(n4==0) v+="\n"+column4; if(n5==0) v+="\n"+column5; if(n6==0) v+="\n"+column6; if(n7==0) v+="\n"+column7; if(n8==0) v+="\n"+column8; if(n9==0) v+="\n"+column9; Alert("These column are not found in the file "+files[z]+":"+"\n"+v); work=false; break; } } f++; } if(i<5) { k=StringLen(text[i])-2; if(StringFind(text[i],"\"",k)!=-1) r=i-1; } if(i<20) continue; string name=text[n1+r]; StringTrimRight(text[n1+r]); StringTrimLeft(text[n1+r]); u= (text[n1+r]); if(e==0) { if(u!=c) continue; e=1; if(g==0) { h=text[1]; if(r>0) h+=", "+text[2]; } } else if(u!=c) break; StringTrimRight(text[n2+r]);//v StringTrimLeft(text[n2+r]);//u u= text[n2+r]; v=StringSubstr(u,0,4)+"."+StringSubstr(u,5,2)+"."+StringSubstr(u,8,2); // Date in form yyyy.mm.dd Print(" v=", v); s=(int)(StringToTime(v)); if(s>t) { y[g]=s; g++; // Date y[g]=StringToDouble(text[n3+r]); g++; // Open interest // Print(" y[g]=", y[g]); Print(" g=", g); y[g]=StringToDouble(text[n4+r]); g++; // Noncommercial positions-long y[g]=StringToDouble(text[n5+r]); g++; // Commercial positions-long y[g]=StringToDouble(text[n6+r]); g++; // Nonreportable positions-long y[g]=StringToDouble(text[n7+r]); g++; // Noncommercial positions-short y[g]=StringToDouble(text[n8+r]); g++; // Commercial positions-short // y1[gyo]=StringToDouble(text[n8+r]); // y[g]=StringToDouble(text[n9+r]); g++; // Noncommercial positions-short // y1[gyo]=StringToDouble(text[n9+r]); // } else { z=50; break; } } FileClose(handle); if(!work || (s!=0 && e==0)) break; } else { Alert("Error: "+(string)GetLastError()+".\nThe location of an error in the code is the place 2"); if(tx=="updated!") GlobalVariableSet(n,0); work=false; break; } if(s==0) { Alert("The code "+c+" is not found in the file "+files[z]+"!"); work=false; break; } if(g==0) { PrintFormat("The updating of the file "+n+" for "+h+" is not required!"); GlobalVariableSet(n,0); break; } if(z==50) break; //--- used files year.txt o++; m+=files[z]+", "; if(o>9) { m+="\n"; o=0; } }//for(z=0; z=0) { // FileWriteDouble(handle,(double)ytime2[i]); double x1= FileWriteDouble(handle,y[i]); if(x1!=sizeof(double)) { work=false; break; } i--; } FileClose(handle); if(work) { if(tx=="created!") Alert("The file "+n+" for "+h+" has been "+tx+"\nUsed files: "+m); else PrintFormat("The file "+n+" for "+h+" has been "+tx); } else { Alert("Error: "+(string)GetLastError()+" at the recording data to the file "+n+"."+ "\nThis file has been deleted.\nThe location of an error in the code is the place 4"); FileDelete(n); GlobalVariableSet(n,0); return(rates_total); } } //if(q==1 || x==1) else { Alert("Error: "+(string)GetLastError()+".\nThe location of an error in the code is the place 3"); GlobalVariableSet(n,0); return(rates_total); } } //421 //read bin mt4 618 if(q==1 || j!=-1) { j=-1; GlobalVariableSet(n,0); if(FileIsExist(n)) { handle=FileOpen(n,FILE_READ|FILE_BIN); // <- place 5 if(handle!=INVALID_HANDLE) { int sizeg=275;// //(!FileIsEnding(handle)) ArrayResize( S3,sizeg); ArrayResize( S2,sizeg); ArrayResize( S1,sizeg); ArrayResize( L3,sizeg); ArrayResize( L2,sizeg); ArrayResize( L1,sizeg); ArrayResize( OI,sizeg); ArrayResize( DT,sizeg); ArrayResize( C3,sizeg); ArrayResize( C2,sizeg); ArrayResize( C1,sizeg); ArrayResize( E3,sizeg); ArrayResize( E2,sizeg); ArrayResize( E1,sizeg); // ytime[i]=(datetime)FileReadDouble(handle); // ArraySetAsSeries(time,false); ArraySetAsSeries( S3,true); ArraySetAsSeries( S2,true); ArraySetAsSeries( S1,true); ArraySetAsSeries( L3,true); ArraySetAsSeries( L2,true); ArraySetAsSeries( L1,true); ArraySetAsSeries( OI,true); ArraySetAsSeries( DT,true); ArraySetAsSeries( C3,true); ArraySetAsSeries( C2,true); ArraySetAsSeries( C1,true); ArraySetAsSeries( E3,true); ArraySetAsSeries( E2,true); ArraySetAsSeries( E1,true); // while(!FileIsEnding(handle)) for(i=sizeg-1; i>=0; i--)// //i=0;ib-p1+1) // Buffer3[i]=EMPTY_VALUE; // else // Buffer3[i]=g3; } if(d>b-p0) d=-1; } else if(d>b-p0-p2) d=-1; } else { if(Indicator>4) { // if(Large) Buffer0[i]=g0; // if(Comm) Buffer1[i]=g1; // if(Specs) Buffer2[i]=g2; } else // Buffer3[i]=g3; // if(Indicator==5 || Indicator==8) Buffer4[i]=0; if(d>=b) d=-1; } } return(rates_total); //906 }//qmatubiosoto379