MS_PentagonW2_d1

Author: *
MS_PentagonW2_d1
0 Views
0 Downloads
0 Favorites
MS_PentagonW2_d1
//+------------------------------------------------------------------+
//|   MS_PentagonW2_d1                                               |
//+------------------------------------------------------------------+
#property copyright "*"
#property link      "*"

#property indicator_chart_window
#property indicator_buffers 0
#property indicator_color1 Red

extern string EX_P_bpoint="2009.11.27 00:00";
extern string EX_P_dpoint="2010.01.08 00:00";
extern string EX_P_bprice="L";
extern string EX_P_dprice="H";
extern int    EX_P_Pmax=20;
extern int    EX_P_Fwidth=1;
extern double EX_P_Fheight=0.05;
extern int    EX_P_RSline=1; // Resistance support line
extern color EX_color1=Blue;
extern color EX_color2=Blue;
extern color EX_color3=Blue;
extern color EX_color4=Blue;
extern color EX_color5=Blue;
extern color EX_color6=Blue;
extern color EX_color7=Aqua;
extern bool EX_show_astrology=true;
extern bool EX_show_price=true;
extern bool EX_show_priceS=true;
extern bool EX_show_lbl_date=false;
extern bool EX_show_lbl_price=true;
double h5,H5;
datetime Tb,Td; int Xb,Xd;
int    xsa,xsb,xsc,xsd,xse,xsf;
double ysa,ysb,ysc,ysd,yse,ysf;
datetime px; double py; int pd;
int    Xsa,Xsb,Xsc,Xsd,Xse,Xsf;
double Ysa,Ysb,Ysc,Ysd,Yse,Ysf;
int    XSA,XSB,XSC,XSD,XSE,XSF;
double YSA,YSB,YSC,YSD,YSE,YSF;
datetime PX; double PY; int PD;
double pi=3.1415926535;
int Pno=0,max_Pno=5;
datetime ST_LX[21]; int ST_LD[21];

string solareclipse01="2005.04.09 00:00"; // The South Pacific
string solareclipse02="2005.10.03 00:00"; // Europe
string solareclipse03="2006.03.29 00:00"; // Africa
string solareclipse04="2006.09.22 00:00"; // Africa
string solareclipse05="2007.03.19 00:00"; // Alaska
string solareclipse06="2007.09.11 00:00"; // South America
string solareclipse07="2008.02.07 00:00"; // The South Pacific
string solareclipse08="2008.08.01 00:00"; // Russia
string solareclipse09="2009.01.26 00:00"; // India
string solareclipse10="2009.07.22 00:00"; // The South Pacific
string solareclipse11="2010.01.15 00:00"; // Africa
string solareclipse12="2010.07.11 00:00"; // Polynesia
string solareclipse13="2011.01.04 00:00"; // Europe
string solareclipse14="2011.06.02 00:00"; // Iceland
string solareclipse15="2011.11.25 00:00"; // Antarctica
string solareclipse16="2012.05.21 00:00"; // 
string solareclipse17="2012.11.14 00:00"; // Australia
string solareclipse18="2013.05.10 00:00"; //
string lunareclipse01="2005.10.17 00:00"; // 
string lunareclipse02="2006.09.08 00:00"; // 
string lunareclipse03="2007.03.04 00:00"; // 
string lunareclipse04="2007.08.28 00:00"; // 
string lunareclipse05="2008.08.17 00:00"; // 
string lunareclipse06="2010.01.01 00:00"; // 
string lunareclipse07="2010.06.26 00:00"; // 
string lunareclipse08="2010.12.21 00:00"; // 
string lunareclipse09="2011.06.11 00:00"; // 
string lunareclipse10="2011.12.10 00:00"; // 
string lunareclipse11="2012.06.04 00:00"; // 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {IndicatorShortName("MS_PentagonW2_d1");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {DelObject();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
{  int i,ic=IndicatorCounted(),fr,ix,iX;
   double ph;
   if(ic==0)
     {max_Pno=EX_P_Pmax; if(EX_P_Pmax>20 ) max_Pno=20;
      Tb=StrToTime(EX_P_bpoint);
      Td=StrToTime(EX_P_dpoint);
      Xb=iBarShift(NULL,0,Tb);
      Xd=iBarShift(NULL,0,Td);
      SetSize(Tb,Xb,Td,Xd);
      PX=Time[Xb+Xsb];
      if(bClose(Xb)<dClose(Xd)) {PY=bClose(Xb); PD=1;} else {PY=bClose(Xb); PD=-1;}
      DrawPentagonL(PX,PY,PD); PushLST(PX,PD);
      DrawText("P00",Time[Xb-(xsc-xsb)/2],"High:"+DoubleToStr(h5,Digits)+","+DoubleToStr(xsc-xsb+1,0),bClose(Xb),White); 
     }

   if(ic==0) fr=Xb-1; else fr=Bars-ic;
   for(i=fr; i>=0; i--)
     {iX=iBarShift(NULL,0,PX);  // Large Pentagon
      if(PD==1)
        {if(iX>=i && i>iX-XSB && Close[i]>PY+YSB*(iX-i)/XSB) // AB break
           {PX=Time[iX+XSC]; PY=PY+YSB; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX>=i && i>iX-XSE && Close[i]<PY-YSE*(iX-i)/XSE) // AE break
           {PX=Time[iX+XSE]; PY=PY-YSE; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSB>=i && i>iX-XSC && Close[i]>PY+YSB) // BC break
           {PX=Time[iX]; PY=PY+YSB*2; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSE>=i && i>iX-XSD && Close[i]<PY-YSE+YSE*((iX-XSE)-i)/(XSD-XSE)) // DE break
           {PX=Time[iX-XSE]; PY=PY-YSE; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSC>=i && i>iX-XSD && Close[i]>PY+YSC-YSC*((iX-XSC)-i)/(XSD-XSC)) // CD break
           {PX=Time[iX-XSC]; PY=PY+YSC; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(i==iX-XSD) // D point
           {PX=Time[iX-XSC]; PY=PY+YSC; PD=-1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
        }
      else
        {if(iX>=i && i>iX-XSB && Close[i]<PY-Ysb*(iX-i)/Xsb) // AB break
           {PX=Time[iX+XSC]; PY=PY-YSB; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX>=i && i>iX-XSE && Close[i]>PY+YSE*(iX-i)/XSE) // AE break
           {PX=Time[iX+XSE]; PY=PY+YSE; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSB>=i && i>iX-XSC && Close[i]<PY-YSB) // BC break
           {PX=Time[iX]; PY=PY-YSB*2; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSE>=i && i>iX-XSD && Close[i]>PY+YSE-YSE*((iX-XSE)-i)/(XSD-XSE)) // DE break
           {PX=Time[iX-XSE]; PY=PY+YSE; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(iX-XSC>=i && i>iX-XSD && Close[i]<PY-YSC+YSC*((iX-XSC)-i)/(XSD-XSC)) // CD break
           {PX=Time[iX-XSC]; PY=PY-YSC; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
         else if(i==iX-XSD) // D point
           {PX=Time[iX-XSC]; PY=PY-YSC; PD=1;
            if(SearchLST(PX,PD)!=0) {DrawPentagonL(PX,PY,PD); PushLST(PX,PD);}
           }
        }
     }

   if(EX_show_price) {DrawPriceL(PX,PY,PD);}
   if(Period()==PERIOD_D1 && EX_show_astrology) ProcEclipse();

   return(0);
}
//+------------------------------------------------------------------+
//|  SetSize                                                         |
//+------------------------------------------------------------------+
void SetSize(datetime tb,int xb,datetime td,int xd)
  {
   int x1=(xb-xd)*1.0/(0.618+(1-0.618)*1.0/2.0);
   xsa=0;
   xsb=x1*(1.0-0.618)*1.0/2.0;
   xsc=x1-xsb;
   xsd=x1;
   xse=x1*1.0/2.0;
   xsf=xse;
   double bh=MathAbs(bClose(xb)-dClose(xd));
   ysa=0.0;
   ysb=bh;
   ysc=bh;
   ysd=0.0;
   yse=bh*0.618;
   ysf=ysb-(ysb+yse)*(0.618*1.0/2.0*MathTan((pi/2.0)*(36.0+18.0)/90.0))/(0.618*1.0/2.0*MathTan((pi/2.0)*72.0/90.0));
   h5=ysb+yse;
   
   Xsa=x1-xsb;
   Xsb=(x1-xsb)+xsb;
   Xsc=(x1-xsb)+xsc;
   Xsd=(x1-xsb)+xsd;
   Xse=(x1-xsb)+xse;
   Xsf=(x1-xsb)+xsf;
   Ysa=ysb;
   Ysb=0;
   Ysc=0;
   Ysd=Ysa;
   Yse=h5;
   Ysf=(ysb+yse)*(0.618*1.0/2.0*MathTan((pi/2.0)*(36.0+18.0)/90.0))/(0.618*1.0/2.0*MathTan((pi/2.0)*72.0/90.0));

   XSA=0;
   XSB=xse;
   XSC=Xsa+xsc+xse;
   XSD=x1*2+(xsc-xsb);
   XSE=x1+(xsc-xsb)/2;
   XSF=XSE;
   YSA=0;
   YSB=h5+ysb;
   YSC=YSB;
   YSD=0;
   YSE=h5;
   YSF=YSB-(YSB+YSE)*(0.618*1.0/2.0*MathTan((pi/2.0)*(36.0+18.0)/90.0))/(0.618*1.0/2.0*MathTan((pi/2.0)*72.0/90.0));
   
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DrawPentagonL(datetime X,double Y,int direction)
  {
   int WX=iBarShift(NULL,0,X);
   datetime TA=X;
   datetime TB=SiftXTime(WX,XSB);
   datetime TC=SiftXTime(WX,XSC);
   datetime TD=SiftXTime(WX,XSD);
   datetime TE=SiftXTime(WX,XSE);
   datetime TF=TE;
   datetime TF1=SiftXTime(WX,XSE-EX_P_Fwidth),TF2=SiftXTime(WX,XSE+EX_P_Fwidth);
   datetime Ta=SiftXTime(WX,Xsa);
   datetime Tb=SiftXTime(WX,Xsb);
   datetime Tc=SiftXTime(WX,Xsc);
   datetime Td=SiftXTime(WX,Xsd);
   datetime Te=SiftXTime(WX,Xse);
   datetime Tf=Te;
   datetime Tf1=SiftXTime(WX,Xse-EX_P_Fwidth),Tf2=SiftXTime(WX,Xse+EX_P_Fwidth);
   double PA=Y;
   double PB=Y+YSB; if(direction==-1) PB=Y-YSB;
   double PC=Y+YSC; if(direction==-1) PC=Y-YSC;
   double PD=Y;
   double PE=Y-YSE; if(direction==-1) PE=Y+YSE;
   double PF=Y+YSF; if(direction==-1) PF=Y-YSF;
   double PF1=PF+h5*EX_P_Fheight,PF2=PF-h5*EX_P_Fheight;
   double Pa=Y+Ysa; if(direction==-1) Pa=Y-Ysa;
   double Pb=Y;
   double Pc=Y;
   double Pd=Y+Ysd; if(direction==-1) Pd=Y-Ysd;
   double Pe=Y+Yse; if(direction==-1) Pe=Y-Yse;
   double Pf=Y+Ysf; if(direction==-1) Pf=Y-Ysf;
   double Pf1=Pf+h5*EX_P_Fheight,Pf2=Pf-h5*EX_P_Fheight;

   
   DrawTLine("P51"+Pno,TA,PA,TB,PB,EX_color4,STYLE_SOLID,EX_P_RSline);
   DrawTLine("P52"+Pno,TB,PB,TC,PC,EX_color4,STYLE_SOLID,1);
   DrawTLine("P53"+Pno,TC,PC,TD,PD,EX_color4,STYLE_SOLID,1);
   DrawTLine("P54"+Pno,TD,PD,TE,PE,EX_color4,STYLE_SOLID,1);
   DrawTLine("P55"+Pno,TE,PE,TA,PA,EX_color4,STYLE_SOLID,EX_P_RSline);
   
   DrawTLine("P56"+Pno,TA,PA,TC,PC,EX_color5,STYLE_DOT,1);
   DrawTLine("P57"+Pno,TB,PB,TD,PD,EX_color5,STYLE_DOT,1);
   DrawTLine("P58"+Pno,TC,PC,TE,PE,EX_color5,STYLE_DOT,1);
   DrawTLine("P59"+Pno,TD,PD,TA,PA,EX_color5,STYLE_DOT,1);
   DrawTLine("P60"+Pno,TE,PE,TB,PB,EX_color5,STYLE_DOT,1);

   DrawTLine("P61"+Pno,Ta,Pa,Tc,Pc,EX_color5,STYLE_SOLID,1);
   DrawTLine("P62"+Pno,Tb,Pb,Td,Pd,EX_color5,STYLE_SOLID,1);
   DrawTLine("P63"+Pno,Tc,Pc,Te,Pe,EX_color5,STYLE_SOLID,1);
   DrawTLine("P64"+Pno,Td,Pd,Ta,Pa,EX_color5,STYLE_SOLID,1);
   DrawTLine("P65"+Pno,Te,Pe,Tb,Pb,EX_color5,STYLE_SOLID,1);
   DrawLF("L",TF,PF1,TF1,PF,TF,PF2,TF2,PF,EX_color6);
   Pno++; Pno=MathMod(Pno,max_Pno);
  }
//+------------------------------------------------------------------+
//|   DrawLF                                                         |
//+------------------------------------------------------------------+
void DrawLF(string n,datetime t1,double p1,datetime t2,double p2,datetime t3,double p3,datetime t4,double p4,color cl) {
   ObjectCreate("P71"+Pno+n,OBJ_TRIANGLE,0,0,0,0,0,0,0);
   ObjectSet("P71"+Pno+n,OBJPROP_STYLE ,STYLE_SOLID);
   ObjectSet("P71"+Pno+n,OBJPROP_COLOR ,cl);
   ObjectSet("P71"+Pno+n,OBJPROP_WIDTH ,1);
   ObjectSet("P71"+Pno+n,OBJPROP_TIME1 ,t1);
   ObjectSet("P71"+Pno+n,OBJPROP_PRICE1,p1);
   ObjectSet("P71"+Pno+n,OBJPROP_TIME2 ,t2);
   ObjectSet("P71"+Pno+n,OBJPROP_PRICE2,p2);
   ObjectSet("P71"+Pno+n,OBJPROP_TIME3 ,t3);
   ObjectSet("P71"+Pno+n,OBJPROP_PRICE3,p3);
   ObjectSet("P71"+Pno+n,OBJPROP_RAY,false);
   ObjectSet("P71"+Pno+n,OBJPROP_BACK,true);

   ObjectCreate("P72"+Pno+n,OBJ_TRIANGLE,0,0,0,0,0,0,0);
   ObjectSet("P72"+Pno+n,OBJPROP_STYLE ,STYLE_SOLID);
   ObjectSet("P72"+Pno+n,OBJPROP_COLOR ,cl);
   ObjectSet("P72"+Pno+n,OBJPROP_WIDTH ,1);
   ObjectSet("P72"+Pno+n,OBJPROP_TIME1 ,t3);
   ObjectSet("P72"+Pno+n,OBJPROP_PRICE1,p3);
   ObjectSet("P72"+Pno+n,OBJPROP_TIME2 ,t4);
   ObjectSet("P72"+Pno+n,OBJPROP_PRICE2,p4);
   ObjectSet("P72"+Pno+n,OBJPROP_TIME3 ,t1);
   ObjectSet("P72"+Pno+n,OBJPROP_PRICE3,p1);
   ObjectSet("P72"+Pno+n,OBJPROP_RAY,false);
   ObjectSet("P72"+Pno+n,OBJPROP_BACK,true);
}
//+------------------------------------------------------------------+
//|   DrawPriceL                                                     |
//+------------------------------------------------------------------+
void DrawPriceL(datetime X,double Y,int direction)
  {
   int WX=iBarShift(NULL,0,X);
   datetime TA=X;
   datetime TB=SiftXTime(WX,XSB);
   datetime TC=SiftXTime(WX,XSC);
   datetime TD=SiftXTime(WX,XSD);
   datetime TE=SiftXTime(WX,XSE);
   datetime TF=TE;
   datetime TF1=SiftXTime(WX,XSE-EX_P_Fwidth),TF2=SiftXTime(WX,XSE+EX_P_Fwidth);
   datetime Ta=SiftXTime(WX,Xsa);
   datetime Tb=SiftXTime(WX,Xsb);
   datetime Tc=SiftXTime(WX,Xsc);
   datetime Td=SiftXTime(WX,Xsd);
   datetime Te=SiftXTime(WX,Xse);
   datetime Tf=Te;
   datetime Tf1=SiftXTime(WX,Xse-EX_P_Fwidth),Tf2=SiftXTime(WX,Xse+EX_P_Fwidth);
   double PA=Y;
   double PB=Y+YSB; if(direction==-1) PB=Y-YSB;
   double PC=Y+YSC; if(direction==-1) PC=Y-YSC;
   double PD=Y;
   double PE=Y-YSE; if(direction==-1) PE=Y+YSE;
   double PF=Y+YSF; if(direction==-1) PF=Y-YSF;
   double PF1=PF+h5*EX_P_Fheight,PF2=PF-h5*EX_P_Fheight;
   double Pa=Y+Ysa; if(direction==-1) Pa=Y-Ysa;
   double Pb=Y;
   double Pc=Y;
   double Pd=Y+Ysd; if(direction==-1) Pd=Y-Ysd;
   double Pe=Y+Yse; if(direction==-1) Pe=Y-Yse;
   double Pf=Y+Ysf; if(direction==-1) Pf=Y-Ysf;
   double Pf1=Pf+h5*EX_P_Fheight,Pf2=Pf-h5*EX_P_Fheight;

   DrawText("P01",TA,Label("A",TA,PA),PA,EX_color7);
   DrawText("P02",TB,Label("B",TB,PB),PB,EX_color7);
   DrawText("P03",TC,Label("C",TC,PC),PC,EX_color7);
   DrawText("P04",TD,Label("D",TD,PD),PD,EX_color7);
   DrawText("P05",TE,Label("E",TE,PE),PE,EX_color7);
   DrawText("P06",TF,Label("F",TF,PF),PF,EX_color7);
   if(EX_show_priceS)
     {DrawText("P07",Ta,Label("a",Ta,Pa),Pa,EX_color7);
      DrawText("P08",Tb,Label("b",Tb,Pb),Pb,EX_color7);
      DrawText("P09",Tc,Label("c",Tc,Pc),Pc,EX_color7);
      DrawText("P10",Td,Label("d",Td,Pd),Pd,EX_color7);
      DrawText("P11",Te,Label("e",Te,Pe),Pe,EX_color7);
     }
}
//+------------------------------------------------------------------+
//| Label                                                            |
//+------------------------------------------------------------------+
string Label(string s,datetime t,double p)
{  string tx;
   tx=s;
   if(EX_show_lbl_date)  tx=tx+" "+StringDT(t);
   if(EX_show_lbl_price) tx=tx+" "+DoubleToStr(p,Digits)+"("+DoubleToStr(p-Close[0],Digits)+")";
   return(tx);
}
//+------------------------------------------------------------------+
//| StringDT                                                         |
//+------------------------------------------------------------------+
string StringDT(datetime t)
{  string tx;
   if(Period()>=PERIOD_D1)
     tx=TimeMonth(t)+"/"+TimeDay(t);
   else if(Period()>=PERIOD_H1)
     tx=TimeMonth(t)+"/"+TimeDay(t)+" "+TimeHour(t)+":"+TimeMinute(t);
   else
     tx=TimeHour(t)+":"+TimeMinute(t);
   return(tx);
}
//+------------------------------------------------------------------+
//| PushLSTACK                                                        |
//+------------------------------------------------------------------+
int PushLST(datetime X,int D)
{  int i;
   for(i=max_Pno-1-1; i>=0; i--)
     {ST_LX[i+1]=ST_LX[i]; ST_LD[i+1]=ST_LD[i];}
   ST_LX[0]=X; ST_LD[0]=D;
   return(0);
}
//+------------------------------------------------------------------+
//| SearchLSTACK                                                      |
//+------------------------------------------------------------------+
int SearchLST(datetime X,int D)
{  int rc,i;
   rc=-1;
   for(i=0; i<=max_Pno-1 ;i++)
      if(ST_LX[i]==X && ST_LD[i]==D) {rc=0; break;}
   return(rc);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DelObject()
{  int i;
   ObjectDelete("P00"); ObjectDelete("P01"); ObjectDelete("P02"); ObjectDelete("P03");
   ObjectDelete("P04"); ObjectDelete("P05"); ObjectDelete("P06"); ObjectDelete("P07");
   ObjectDelete("P08"); ObjectDelete("P09"); ObjectDelete("P10"); ObjectDelete("P11");
   ObjectDelete("P12");
   for(i=0; i<=max_Pno; i++)
     {ObjectDelete("P51"+i); ObjectDelete("P52"+i); ObjectDelete("P53"+i); 
      ObjectDelete("P54"+i); ObjectDelete("P55"+i); ObjectDelete("P56"+i); 
      ObjectDelete("P57"+i); ObjectDelete("P58"+i); ObjectDelete("P59"+i); 
      ObjectDelete("P60"+i); ObjectDelete("P61"+i); ObjectDelete("P62"+i);
      ObjectDelete("P63"+i); ObjectDelete("P64"+i); ObjectDelete("P65"+i);
      ObjectDelete("P71"+i+"S"); ObjectDelete("P72"+i+"S");
      ObjectDelete("P71"+i+"L"); ObjectDelete("P72"+i+"L");
     }
   ObjectDelete("PS"+solareclipse01); ObjectDelete("PS"+solareclipse02); ObjectDelete("PS"+solareclipse03);
   ObjectDelete("PS"+solareclipse04); ObjectDelete("PS"+solareclipse05); ObjectDelete("PS"+solareclipse06);
   ObjectDelete("PS"+solareclipse07); ObjectDelete("PS"+solareclipse08); ObjectDelete("PS"+solareclipse09);
   ObjectDelete("PS"+solareclipse10); ObjectDelete("PS"+solareclipse11); ObjectDelete("PS"+solareclipse12);
   ObjectDelete("PS"+solareclipse13); ObjectDelete("PS"+solareclipse14); ObjectDelete("PS"+solareclipse15);
   ObjectDelete("PS"+solareclipse16); ObjectDelete("PS"+solareclipse17); ObjectDelete("PS"+solareclipse18);
   ObjectDelete("PL"+lunareclipse01); ObjectDelete("PL"+lunareclipse02); ObjectDelete("PL"+lunareclipse03);
   ObjectDelete("PL"+lunareclipse04); ObjectDelete("PL"+lunareclipse05); ObjectDelete("PL"+lunareclipse06);
   ObjectDelete("PL"+lunareclipse07); ObjectDelete("PL"+lunareclipse08); ObjectDelete("PL"+lunareclipse09);
   ObjectDelete("PL"+lunareclipse10); ObjectDelete("PL"+lunareclipse11);
}
//+------------------------------------------------------------------+
//| ProcEclipse                                                      |
//+------------------------------------------------------------------+
void ProcEclipse()
{  
   SolarEclipse(solareclipse01);
   SolarEclipse(solareclipse02);
   SolarEclipse(solareclipse03);
   SolarEclipse(solareclipse04);
   SolarEclipse(solareclipse05);
   SolarEclipse(solareclipse06);
   SolarEclipse(solareclipse07);
   SolarEclipse(solareclipse08);
   SolarEclipse(solareclipse09);
   SolarEclipse(solareclipse10);
   SolarEclipse(solareclipse11);
   SolarEclipse(solareclipse12);
   SolarEclipse(solareclipse13);
   SolarEclipse(solareclipse14);
   SolarEclipse(solareclipse15);
   SolarEclipse(solareclipse16);
   SolarEclipse(solareclipse17);
   SolarEclipse(solareclipse18);
   LunarEclipse(lunareclipse01);
   LunarEclipse(lunareclipse02);
   LunarEclipse(lunareclipse03);
   LunarEclipse(lunareclipse04);
   LunarEclipse(lunareclipse05);
   LunarEclipse(lunareclipse06);
   LunarEclipse(lunareclipse07);
   LunarEclipse(lunareclipse08);
   LunarEclipse(lunareclipse09);
   LunarEclipse(lunareclipse10);
   LunarEclipse(lunareclipse11);
}
//+------------------------------------------------------------------+
//| SolarEclipse                                                     |
//+------------------------------------------------------------------+
int SolarEclipse(string tt)
{  int ib;
   datetime dt=StrToTime(tt);
   datetime bf=Time[Bars-1]; datetime bt=Time[0];
   if(bf<=dt && dt<=bt)
     {ib=iBarShift(NULL,0,dt);
      DrawText("PS"+tt,dt,"S",High[ib]+(High[ib]-Low[ib])*1.5,HotPink);
     } 
   else if(dt>Time[0])  DrawText("PS"+tt,dt,"S",Close[0],HotPink); 
}
//+------------------------------------------------------------------+
//| LunarEclipse                                                     |
//+------------------------------------------------------------------+
int LunarEclipse(string tt)
{  int ib;
   datetime dt=StrToTime(tt);
   datetime bf=Time[Bars-1]; datetime bt=Time[0];
   if(bf<=dt && dt<=bt)
     {ib=iBarShift(NULL,0,dt);
      DrawText("PL"+tt,dt,"L",Low[ib]-(High[ib]-Low[ib]),Aqua);
     } 
   else if(dt>Time[0])  DrawText("PL"+tt,dt,"L",Close[0],Aqua); 
}
//+------------------------------------------------------------------+
//|   DrawTLine                                                      |
//+------------------------------------------------------------------+
void DrawTLine(string no,datetime t1,double p1,datetime t2,double p2,color cl,int st,int w)
{
   if(ObjectFind(no)<0) ObjectCreate(no,OBJ_TREND,0,0,0,0,0);
   ObjectSet(no,OBJPROP_STYLE ,st);
   ObjectSet(no,OBJPROP_COLOR ,cl);
   ObjectSet(no,OBJPROP_WIDTH ,w);
   ObjectSet(no,OBJPROP_TIME1 ,t1);
   ObjectSet(no,OBJPROP_PRICE1,p1);
   ObjectSet(no,OBJPROP_TIME2 ,t2);
   ObjectSet(no,OBJPROP_PRICE2,p2);
   ObjectSet(no,OBJPROP_RAY,false);
   ObjectSet(no,OBJPROP_BACK,false);
}
//+------------------------------------------------------------------+
//|   DrawText                                                       |
//+------------------------------------------------------------------+
void DrawText(string no,datetime tb,string tx,double p,color cl) 
{  ObjectCreate(no,OBJ_TEXT,0,0,0);
   ObjectSet(no,OBJPROP_TIME1   ,tb);
   ObjectSet(no,OBJPROP_PRICE1  ,p);
   ObjectSet(no,OBJPROP_COLOR   ,cl);
   ObjectSet(no,OBJPROP_FONTSIZE,9);
   ObjectSetText(no,tx);
}
//+------------------------------------------------------------------+
//   SiftXTime                                                       |
//+------------------------------------------------------------------+
datetime SiftXTime(int x,int sf)
{  datetime dt;
   if(x-sf>=0)
     {dt=Time[x-sf];}
   else
     {dt=Timeshift(Time[0],sf-x);}
   return(dt);
}
//+------------------------------------------------------------------+
//   Timeshift                                                       |
//+------------------------------------------------------------------+
datetime Timeshift (datetime dt,int sf) {
   int ty=TimeYear(dt);
   int tm=TimeMonth(dt);
   int td=TimeDay(dt);
   int th=TimeHour(dt);
   int ti=TimeMinute(dt);
   int i;
   
   for(i=1; i<=sf; i++)
     {if     (Period()==PERIOD_M1 ) ti=ti+1;
      else if(Period()==PERIOD_M5 ) ti=ti+5;
      else if(Period()==PERIOD_M15) ti=ti+15;
      else if(Period()==PERIOD_M30) ti=ti+30;
      else if(Period()==PERIOD_H1 ) th=th+1;
      else if(Period()==PERIOD_H4 ) th=th+4;
      else if(Period()==PERIOD_D1 ) td=td+1;
      else if(Period()==PERIOD_W1 ) td=td+7;
      else if(Period()==PERIOD_MN1) tm=tm+1;

      if(ti>=60) {ti=ti-60; th++;}
      if(th>=24) {th=th-24; td++;}
      if(tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12) {if(td>31) {tm++; td=td-31;}}
      else if(tm==2) {
                      if(MathMod(ty,4)==0)    
                        {if(td>29) {tm++; td=td-29;}} 
                      else 
                        {if(td>28) {tm++; td=td-28;}}
                     }
      else if(tm==4 || tm==6 || tm==9 || tm==11) if(td>30) {tm++; td=td-30;}
      if(tm>12) {tm=1; ty++;}
     }
   return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti));
}
//+------------------------------------------------------------------+
//   bClose                                                          |
//+------------------------------------------------------------------+
double bClose(int x)
{  double p;
   if     (EX_P_bprice=="O") p=Open[x];
   else if(EX_P_bprice=="H") p=High[x];
   else if(EX_P_bprice=="L") p=Low [x];
   else                      p=Close[x];
   return(p);
}
//+------------------------------------------------------------------+
//   dClose                                                          |
//+------------------------------------------------------------------+
double dClose(int x)
{  double p;
   if     (EX_P_dprice=="O") p=Open[x];
   else if(EX_P_dprice=="H") p=High[x];
   else if(EX_P_dprice=="L") p=Low [x];
   else                      p=Close[x];
   return(p);
}

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