Author: Candid
Price Data Components
Series array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Multy8
//+------------------------------------------------------------------+
//|                                                       Multy8.mq4 |
//|                                                           Candid |
//|                                         http://candid.110mb.com/ |
//+------------------------------------------------------------------+
string IndName="M8";

#define TextColor Black
#define Color1 Gold
#define Color2 FireBrick
#define Color3 Navy
#define Color4 Blue
#define Color5 DarkGreen
#define Color6 Purple
#define Color7 DodgerBlue
#define Color8 DarkGoldenrod

extern string Smbl1 = "XAUUSD";
extern string Smbl2 = "_DXY";
extern string Smbl3 = "_QM";
extern string Smbl4 = "AUDUSD";
extern string Smbl5 = "GBPUSD";
extern string Smbl6 = "USDJPY";
extern string Smbl7 = "USDCHF";
extern string Smbl8 = "USDCAD";
extern int BP=1440;  //  Ïåðèîä ðàñ÷¸òà áàçû
extern int Depth=7200;  //

#property copyright "Candid"
#property link      "http://candid.110mb.com/"

#property indicator_separate_window
#property indicator_buffers 8
//#property indicator_color 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_color5 Color5
#property indicator_width5 2
#property indicator_color6 Color6
#property indicator_width6 2
#property indicator_color7 Color7
#property indicator_width7 2
#property indicator_color8 Color8
#property indicator_width8 2

#property indicator_level1 0.0
#property indicator_levelcolor TextColor

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;
double Buf4[];

int FImTime5;
double P5;
double R5;
double BBuf5[];
double SBuf5[];
double SumB5;
double SumS5;
double B5;
double S5;
double Buf5[];

int FImTime6;
double P6;
double R6;
double BBuf6[];
double SBuf6[];
double SumB6;
double SumS6;
double B6;
double S6;
double Buf6[];

int FImTime7;
double P7;
double R7;
double BBuf7[];
double SBuf7[];
double SumB7;
double SumS7;
double B7;
double S7;
double Buf7[];

int FImTime8;
double P8;
double R8;
double BBuf8[];
double SBuf8[];
double SumB8;
double SumS8;
double B8;
double S8;
double Buf8[];

int pb;
bool IsBase;
double RecBP;

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;
   SumB5 = 0.0;
   SumS5 = 0.0;
   SumB6 = 0.0;
   SumS6 = 0.0;
   SumB7 = 0.0;
   SumS7 = 0.0;
   SumB8 = 0.0;
   SumS8 = 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);
   ArrayResize(BBuf5,BP);
   ArrayResize(SBuf5,BP);
   ArrayResize(BBuf6,BP);
   ArrayResize(SBuf6,BP);
   ArrayResize(BBuf7,BP);
   ArrayResize(SBuf7,BP);
   ArrayResize(BBuf8,BP);
   ArrayResize(SBuf8,BP);

//  ShortName = IndName+"("+Smbl1+","+Smbl2+","+Smbl3+","+Smbl4+","+Smbl5+","+Smbl6+","+Smbl7+","+Smbl8+","+BP+","+Depth+")";
   ShortName=Smbl1+","+Smbl2+","+Smbl3+","+Smbl4+","+Smbl5+","+Smbl6+","+Smbl7+","+Smbl8+","+BP+","+Depth;
//  ShortName = IndName;
   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);

   SetIndexBuffer(4,Buf5);
   SetIndexStyle(4,DRAW_LINE,EMPTY,2);
   SetIndexLabel(4,Smbl5);

   SetIndexBuffer(5,Buf6);
   SetIndexStyle(5,DRAW_LINE,EMPTY,2);
   SetIndexLabel(5,Smbl6);

   SetIndexBuffer(6,Buf7);
   SetIndexStyle(6,DRAW_LINE,EMPTY,2);
   SetIndexLabel(6,Smbl7);

   SetIndexBuffer(7,Buf8);
   SetIndexStyle(7,DRAW_LINE,EMPTY,2);
   SetIndexLabel(7,Smbl8);

   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");
   ObjectDelete(IndName+"Line5");
   ObjectDelete(IndName+"Smbl5");
   ObjectDelete(IndName+"Line6");
   ObjectDelete(IndName+"Smbl6");
   ObjectDelete(IndName+"Line7");
   ObjectDelete(IndName+"Smbl7");
   ObjectDelete(IndName+"Line8");
   ObjectDelete(IndName+"Smbl8");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator reset function                                  |
//+------------------------------------------------------------------+
int Reset() 
  {
   int win_idx=WindowFind(ShortName);
   SetSmblLabel(IndName+"Line1",win_idx,"_",24,1,50,0,Color1);
   SetSmblLabel(IndName+"Smbl1",win_idx,Smbl1,10,1,3,32,TextColor);
   SetSmblLabel(IndName+"Line2",win_idx,"_",24,1,50,16,Color2);
   SetSmblLabel(IndName+"Smbl2",win_idx,Smbl2,10,1,3,48,TextColor);
   SetSmblLabel(IndName+"Line3",win_idx,"_",24,1,50,32,Color3);
   SetSmblLabel(IndName+"Smbl3",win_idx,Smbl3,10,1,3,64,TextColor);
   SetSmblLabel(IndName+"Line4",win_idx,"_",24,1,50,48,Color4);
   SetSmblLabel(IndName+"Smbl4",win_idx,Smbl4,10,1,3,80,TextColor);
   SetSmblLabel(IndName+"Line5",win_idx,"_",24,1,50,64,Color5);
   SetSmblLabel(IndName+"Smbl5",win_idx,Smbl5,10,1,3,96,TextColor);
   SetSmblLabel(IndName+"Line6",win_idx,"_",24,1,50,80,Color6);
   SetSmblLabel(IndName+"Smbl6",win_idx,Smbl6,10,1,3,112,TextColor);
   SetSmblLabel(IndName+"Line7",win_idx,"_",24,1,50,96,Color7);
   SetSmblLabel(IndName+"Smbl7",win_idx,Smbl7,10,1,3,128,TextColor);
   SetSmblLabel(IndName+"Line8",win_idx,"_",24,1,50,112,Color8);
   SetSmblLabel(IndName+"Smbl8",win_idx,Smbl8,10,1,3,144,TextColor);

   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;
   SumB5 = 0.0;
   SumS5 = 0.0;
   SumB6 = 0.0;
   SumS6 = 0.0;
   SumB7 = 0.0;
   SumS7 = 0.0;
   SumB8 = 0.0;
   SumS8 = 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);
   ImBars=iBars(Smbl5,0);
   FImTime5=iTime(Smbl5,0,ImBars-1);
   ImBars=iBars(Smbl6,0);
   FImTime6=iTime(Smbl6,0,ImBars-1);
   ImBars=iBars(Smbl7,0);
   FImTime7=iTime(Smbl7,0,ImBars-1);
   ImBars=iBars(Smbl8,0);
   FImTime8=iTime(Smbl8,0,ImBars-1);

   PreBars = 0;
   BarTime = 0;
   if(Depth==0) return(Bars-1);
   else return(Depth);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() 
  {
   int pos;
   int IndTime;

   if(Bars==PreBars) 
     {
      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;
      Buf5[0] = (iClose(Smbl5,0,iBarShift(Smbl5,0,Time[0]))-B5)*S5;
      Buf6[0] = (iClose(Smbl6,0,iBarShift(Smbl6,0,Time[0]))-B6)*S6;
      Buf7[0] = (iClose(Smbl7,0,iBarShift(Smbl7,0,Time[0]))-B7)*S7;
      Buf8[0] = (iClose(Smbl8,0,iBarShift(Smbl8,0,Time[0]))-B8)*S8;
      return(0);
     }
   if(Bars-PreBars==1 && BarTime==Time[1]) StartPos=1;
   else StartPos=Reset();

   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--;

   PreBars= Bars;
   BarTime=Time[0];

   for(pos=StartPos;pos>0;pos--) 
     {
      IndTime=Time[pos];
      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);
      GetSmblData(Smbl5,FImTime5,IndTime,pb,BBuf5,SBuf5,SumB5,SumS5,P5);
      GetSmblData(Smbl6,FImTime6,IndTime,pb,BBuf6,SBuf6,SumB6,SumS6,P6);
      GetSmblData(Smbl7,FImTime7,IndTime,pb,BBuf7,SBuf7,SumB7,SumS7,P7);
      GetSmblData(Smbl8,FImTime8,IndTime,pb,BBuf8,SBuf8,SumB8,SumS8,P8);
      pb++;
      if(pb>=BP) 
        {
         pb=0;
         IsBase=true;
        }
      if(IsBase) 
        {
         GetSmblBS(BBuf1,SBuf1,SumB1,SumS1,B1,S1);
         Buf1[pos]=(P1-B1)*S1;
         GetSmblBS(BBuf2,SBuf2,SumB2,SumS2,B2,S2);
         //      Buf2[pos] = (B2-P2)*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;
         GetSmblBS(BBuf5,SBuf5,SumB5,SumS5,B5,S5);
         Buf5[pos]=(P5-B5)*S5;
         GetSmblBS(BBuf6,SBuf6,SumB6,SumS6,B6,S6);
         Buf6[pos]=(P6-B6)*S6;
         GetSmblBS(BBuf7,SBuf7,SumB7,SumS7,B7,S7);
         Buf7[pos]=(P7-B7)*S7;
         GetSmblBS(BBuf8,SBuf8,SumB8,SumS8,B8,S8);
         Buf8[pos]=(P8-B8)*S8;
           } else {
         Buf1[pos] = 0.0;
         Buf2[pos] = 0.0;
         Buf3[pos] = 0.0;
         Buf4[pos] = 0.0;
         Buf5[pos] = 0.0;
         Buf6[pos] = 0.0;
         Buf7[pos] = 0.0;
         Buf8[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<fFImTime) return;
   int shift=iBarShift(Symb,0,fIndTime);
   double fHigh= iHigh(Symb,0,shift);
   double fLow = iLow(Symb,0,shift);
   double fRange=fHigh-fLow;
   fPrice=0.5*(fHigh+fLow);
//  fPrice = iClose(Symb,0,shift);
   fBBuf[fpb] = fPrice;
   fSBuf[fpb] = fRange;
   fSumB += fPrice;
   fSumS += fRange;
   return;
  }
//+------------------------------------------------------------------+
void GetSmblBS(double &fBBuf[],double &fSBuf[],double &fSumB,double &fSumS,double &fBase,double &fScale) 
  {
   fBase=fSumB*RecBP;
   if(fSumS!=0) fScale=BP/fSumS;
   fSumB -= fBBuf[pb];
   fSumS -= fSBuf[pb];
   return;
  }
//+------------------------------------------------------------------+
void SetSmblLabel(string LabelName,int Wnd,string Text,int Size,int Corner,int X,int Y,color Color) 
  {
   if(ObjectFind(LabelName)!=Wnd) ObjectCreate(LabelName,OBJ_LABEL,Wnd,0,0);
   ObjectSet(LabelName,OBJPROP_CORNER,Corner);
   ObjectSet(LabelName,OBJPROP_XDISTANCE,X);
   ObjectSet(LabelName,OBJPROP_YDISTANCE,Y);
   ObjectSetText(LabelName,Text,Size,"Rockwell Condensed",Color);
   return;
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---