//+------------------------------------------------------------------+ //| Multy4.mq4 | //| Candid | //| http://candid.110mb.com/ | //+------------------------------------------------------------------+ string IndName="Multy4"; //#define Color #define Color1 Blue #define Color2 FireBrick #define Color3 Navy #define Color4 Gold extern string Smbl1 = "EURUSD"; extern string Smbl2 = "_DXY"; extern string Smbl3 = "_QM"; extern string Smbl4 = "XAUUSD"; extern int BP=1440; // Период расчёта базы extern int Depth=7200; // #property copyright "Candid" #property link "http://candid.110mb.com/" #property indicator_separate_window #property indicator_buffers 4 //#property indicator_color //#property indicator_width 2 #property indicator_color1 Color1 #property indicator_width1 2 #property indicator_color2 Color2 #property indicator_width2 2 #property indicator_color3 Color3 #property indicator_width3 2 #property indicator_color4 Color4 #property indicator_width4 2 #property indicator_level1 0.0 #property indicator_levelcolor Black int PreBars = 0; int BarTime = 0; int StartPos; int FImTime1; double P1; double R1; double BBuf1[]; double SBuf1[]; double SumB1; double SumS1; double B1; double S1; double Buf1[]; int FImTime2; double P2; double R2; double BBuf2[]; double SBuf2[]; double SumB2; double SumS2; double B2; double S2; double Buf2[]; int FImTime3; double P3; double R3; double BBuf3[]; double SBuf3[]; double SumB3; double SumS3; double B3; double S3; double Buf3[]; int FImTime4; double P4; double R4; double BBuf4[]; double SBuf4[]; double SumB4; double SumS4; double B4; double S4; int pb; bool IsBase; double RecBP; double Buf4[]; string ShortName; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { pb=0; SumB1 = 0.0; SumS1 = 0.0; SumB2 = 0.0; SumS2 = 0.0; SumB3 = 0.0; SumS3 = 0.0; SumB4 = 0.0; SumS4 = 0.0; IsBase= false; RecBP = 1.0/BP; ArrayResize(BBuf1,BP); ArrayResize(SBuf1,BP); ArrayResize(BBuf2,BP); ArrayResize(SBuf2,BP); ArrayResize(BBuf3,BP); ArrayResize(SBuf3,BP); ArrayResize(BBuf4,BP); ArrayResize(SBuf4,BP); ShortName=IndName+"("+Smbl1+","+Smbl2+","+Smbl3+","+Smbl4+","+BP+","+Depth+")"; IndicatorShortName(ShortName); SetIndexBuffer(0,Buf1); SetIndexStyle(0,DRAW_LINE,EMPTY,2); SetIndexLabel(0,Smbl1); SetIndexBuffer(1,Buf2); SetIndexStyle(1,DRAW_LINE,EMPTY,2); SetIndexLabel(1,Smbl2); SetIndexBuffer(2,Buf3); SetIndexStyle(2,DRAW_LINE,EMPTY,2); SetIndexLabel(2,Smbl3); SetIndexBuffer(3,Buf4); SetIndexStyle(3,DRAW_LINE,EMPTY,2); SetIndexLabel(3,Smbl4); PreBars = 0; BarTime = 0; return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { Comment(""); // ObjectDelete(IndName+"Line"); // ObjectDelete(IndName+"Smbl"); ObjectDelete(IndName+"Line1"); ObjectDelete(IndName+"Smbl1"); ObjectDelete(IndName+"Line2"); ObjectDelete(IndName+"Smbl2"); ObjectDelete(IndName+"Line3"); ObjectDelete(IndName+"Smbl3"); ObjectDelete(IndName+"Line4"); ObjectDelete(IndName+"Smbl4"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator reset function | //+------------------------------------------------------------------+ int Reset() { int win_idx=WindowFind(ShortName); // SetSmblLabel(IndName+"Line",win_idx,"_",24,1,50,0,Color); // SetSmblLabel(IndName+"Smbl",win_idx,Smbl,10,1,3,32,Black); SetSmblLabel(IndName+"Line1",win_idx,"_",24,1,50,0,Color1); SetSmblLabel(IndName+"Smbl1",win_idx,Smbl1,10,1,3,32,Black); SetSmblLabel(IndName+"Line2",win_idx,"_",24,1,50,16,Color2); SetSmblLabel(IndName+"Smbl2",win_idx,Smbl2,10,1,3,48,Black); SetSmblLabel(IndName+"Line3",win_idx,"_",24,1,50,32,Color3); SetSmblLabel(IndName+"Smbl3",win_idx,Smbl3,10,1,3,64,Black); SetSmblLabel(IndName+"Line4",win_idx,"_",24,1,50,48,Color4); SetSmblLabel(IndName+"Smbl4",win_idx,Smbl4,10,1,3,80,Black); pb=0; SumB1 = 0.0; SumS1 = 0.0; SumB2 = 0.0; SumS2 = 0.0; SumB3 = 0.0; SumS3 = 0.0; SumB4 = 0.0; SumS4 = 0.0; IsBase= false; RecBP = 1.0/BP; int ImBars=iBars(Smbl1,0); FImTime1=iTime(Smbl1,0,ImBars-1); ImBars=iBars(Smbl2,0); FImTime2=iTime(Smbl2,0,ImBars-1); ImBars=iBars(Smbl3,0); FImTime3=iTime(Smbl3,0,ImBars-1); ImBars=iBars(Smbl4,0); FImTime4=iTime(Smbl4,0,ImBars-1); PreBars = 0; BarTime = 0; return(Depth); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int pos; int IndTime; if(Bars==PreBars) { // Buf[0] = (iClose(Smbl,0,iBarShift(Smbl,0,Time[0]))-B)*S; Buf1[0] = (iClose(Smbl1,0,iBarShift(Smbl1,0,Time[0]))-B1)*S1; Buf2[0] = (iClose(Smbl2,0,iBarShift(Smbl2,0,Time[0]))-B2)*S2; Buf3[0] = (iClose(Smbl3,0,iBarShift(Smbl3,0,Time[0]))-B3)*S3; Buf4[0] = (iClose(Smbl4,0,iBarShift(Smbl4,0,Time[0]))-B4)*S4; return(0); } if(Bars-PreBars==1 && BarTime==Time[1]) StartPos=1; else StartPos=Reset(); PreBars= Bars; BarTime=Time[0]; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; StartPos = Bars - counted_bars; if(counted_bars==0) StartPos--; for(pos=StartPos;pos>0;pos--) { IndTime=Time[pos]; // GetSmblData(SmbFImTimel,FImTime,IndTime,pb,BBuf,SBuf,SumB,SumS,P); GetSmblData(Smbl1,FImTime1,IndTime,pb,BBuf1,SBuf1,SumB1,SumS1,P1); GetSmblData(Smbl2,FImTime2,IndTime,pb,BBuf2,SBuf2,SumB2,SumS2,P2); GetSmblData(Smbl3,FImTime3,IndTime,pb,BBuf3,SBuf3,SumB3,SumS3,P3); GetSmblData(Smbl4,FImTime4,IndTime,pb,BBuf4,SBuf4,SumB4,SumS4,P4); pb++; if(pb>=BP) { pb=0; IsBase=true; } if(IsBase) { // GetSmblBS(BBuf,SBuf,SumB,SumS,B,S); GetSmblBS(BBuf1,SBuf1,SumB1,SumS1,B1,S1); Buf1[pos]=(P1-B1)*S1; GetSmblBS(BBuf2,SBuf2,SumB2,SumS2,B2,S2); // Buf2[pos] = (B2-C2)*S2; Buf2[pos]=(P2-B2)*S2; GetSmblBS(BBuf3,SBuf3,SumB3,SumS3,B3,S3); Buf3[pos]=(P3-B3)*S3; GetSmblBS(BBuf4,SBuf4,SumB4,SumS4,B4,S4); Buf4[pos]=(P4-B4)*S4; } else { Buf1[pos] = 0.0; Buf2[pos] = 0.0; Buf3[pos] = 0.0; Buf4[pos] = 0.0; } } // pos=StartPos;pos>0;pos--) return(0); } //+------------------------------------------------------------------+ void GetSmblData(string Symb,int fFImTime,int fIndTime,int fpb,double &fBBuf[],double &fSBuf[],double &fSumB,double &fSumS,double &fPrice) { if(fIndTime