MiniSinyal_v1_1 code error

 
//+------------------------------------------------------------------+
//|                                              MiniSinyal_v1_1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window  //indicator_separate_window 
extern string Window_Settings   = "--------------------------";
extern int Jendela = 0; //0=Main Chart
extern int Pojok   = 1; //0=Left Top; 1=Right Top; 2=Left Bottom; 3= Right Bottom
extern int jX = 0;
extern int jY = 0;
extern string BuySeLL_Settings1 = "--------------------------";
extern int TF1 = 30;
extern int TF2 = 15;
extern int TF3 =  5;
extern string BuySeLL_Settings2 = "--------------------------";
extern int MAFastPeriod = 2; 
extern int MAFastMethod = 3; 
extern int MAFastApply_To = 0;
extern int MAFastShift = 0;
extern string BuySeLL_Settings3 = "--------------------------";
extern int MASlowPeriod = 4; 
extern int MASlowMethod = 3;
extern int MASlowApply_To = 1;
extern int MASlowShift = 0;

extern string TRend_Settings1 = "--------------------------";
extern int tMAFastPeriod = 1; 
extern int tMAFastMethod = 0; 
extern int tMAFastApply_To = 0;
extern int tMAFastShift = 0;
extern string TRend_Settings2 = "--------------------------";
extern int tMASlowPeriod = 20; 
extern int tMASlowMethod = 0;
extern int tMASlowApply_To = 0;
extern int tMASlowShift = 0;
//--------------------------------------------------------------------
extern string Display_Settings  = "--------------------------";
//extern color LegendColor = SteelBlue;
extern color Color_Up = LimeGreen;
extern color Color_Dn = OrangeRed;
extern color NeutralColor = Gainsboro;
extern color Info_Color = Gainsboro;


extern color TP1_color = ForestGreen;
extern color TP2_color = DodgerBlue;
extern color TP3_color = OrangeRed;
//--------------------------------------------------------------------
string CandleUp = "n"; // pakai font "Wingdings"
string CandleDn = "n"; // pakai font "Wingdings"
string CandleNt = "ª"; // pakai font "Wingdings"
//--------------------------------------------------------------------
string CrossUp  = "p"; // pakai font "Wingdings 3"
string CrossDn  = "q"; // pakai font "Wingdings 3"
//+------------------------------------------------------------------+
// --- variabel Daily_Av --------------------------------------------+
int    R1, R5, R10, R20, RAvg, n, i;
string Teks_ReRata = "", Teks_Rerata_Kemarin ="";
color  warna_ReRata, WarnaTeks;
//-------------------------------------------------------------------+
// Variable
double vA, vB, vC, vD, LastHigh, LastLow, x, hrg, sprd;
double TP1, TP2, TP3, Periode;
int TF, posX, posY, tpX, tpY;
string Price, BSstatus, BSstatus1, BSstatus2, BSstatus3, Teks_Menit, Teks_Detik, Sisa_Waktu, Ket;
string OpenStatus="", tPeriode="";
string CandleSymbol, TrendSymbol, UpSymbol="p",  DnSymbol="q", NtSymbol="«";
color  BS_Color, TR_color, CandleColor, TextColor;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   jX=jX+16; tpX=jX;
   jY=jY+24; tpY=jY;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll(0,OBJ_LABEL);
   ObjectsDeleteAll(1,OBJ_LABEL);
   ObjectsDeleteAll(2,OBJ_LABEL);
   ObjectsDeleteAll(3,OBJ_LABEL);

   for(int i = ObjectsTotal() - 1; i >= 0; i--)
     {
       string label = ObjectName(i);
       if(StringSubstr(label, 0, 3) != "MS_")
           continue;
       ObjectDelete(label);   
     }   
     
   for(int z = ObjectsTotal() - 1; z >= 0; z--)
     {
       string anu = ObjectName(z);
       if(StringSubstr(anu, 0, 4) != "TPMS")
           continue;
       ObjectDelete(anu);   
     }    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   //int    counted_bars=IndicatorCounted();
//----
// --- AWAL BAGIAN MENGHITUNG PIVOT ---
//---- Name for DataWindow and indicator subwindow label
   //IndicatorShortName(WindowName); 
   SetIndexDrawBegin(0,1);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

   int counted_bars = IndicatorCounted();
   int limit, i;
   
   //---- Indicator Calculation ----
   if(counted_bars == 0)
     {
       x = Period();
       if(x > 240) 
           return(-1);       
     }
   if(counted_bars < 0) 
       return(-1);
   //---- last counted bar will be recounted
   //   if(counted_bars>0) counted_bars--;
   limit = (Bars - counted_bars) - 1;
 
   // ------------------- 
   // ---   AWAL AWAS ---
   // -------------------
   for(i = limit; i >= 0; i--)
     { 
       if(High[i+1] > LastHigh) 
           LastHigh = High[i+1];
       
       if(Low[i+1] < LastLow) 
           LastLow=Low[i+1];
       
       if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
         { 
           LastLow = Open[i]; 
           LastHigh = Open[i];
         }
         
       //---- Pivot Setup ----
       double rates[1][6],yesterday_volume,yesterday_close,yesterday_high,yesterday_low,yesterday_open;
       ArrayCopyRates(rates, Symbol(), PERIOD_D1);

       if(DayOfWeek() == 1)
          {
           if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,1)) == 5)
              {
               yesterday_volume = rates[1][5];
               yesterday_close = rates[1][4];
               yesterday_high = rates[1][3];
               yesterday_low = rates[1][2];
               yesterday_open = rates[1][1];
       
              }
           else
              {
               for(int d = 5;d>=0;d--)
                   {
                    if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,d)) == 5)
                       {
                        yesterday_volume = rates[d][5];
                        yesterday_close = rates[d][4];
                        yesterday_high = rates[d][3];
                        yesterday_low = rates[d][2];
                        yesterday_open = rates[d][1];
                       }
         
                   }  
      
              }
          }
       else
          {
           yesterday_close = rates[1][4];
           yesterday_high = rates[1][3];
           yesterday_low = rates[1][2];
           yesterday_open = rates[1][1];
          }

       //---- Calculate Pivots ----
       double R = yesterday_high - yesterday_low;//range
       double p = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot
       double r3 = (2*p)+(yesterday_high-(2*yesterday_low));// Resistance 3
       double r2 = p+(yesterday_high - yesterday_low);// Resistance point 2
       double r1 = (2*p)-yesterday_low;// Resistance point 1
       double s1 = (2*p)-yesterday_high;// Support point 1
       double s2 = p-(yesterday_high - yesterday_low);// Support point 2
       double s3 = (2*p)-((2* yesterday_high)-yesterday_low);// Support point 3

       double m0 = (s2 + s3)/2;
       double m1 = (s1 + s2)/2;
       double m2 = (p + s1)/2;
       double m3 = (p + r1)/2; 
       double m4 = (r1 + r2)/2;
       double m5 = (r2 + r3)/2; 
     } // end for
// --- AKHIR BAGIAN MENGHITUNG PIVOT ---


   vA = iMA(Symbol(), TF1, MAFastPeriod, MAFastShift, MAFastMethod, MAFastApply_To, 0);
   vB = iMA(Symbol(), TF1, MASlowPeriod, MASlowShift, MASlowMethod, MASlowApply_To, 0);
   if (vA>vB)
       { BSstatus1="BUY" ;}
   else { BSstatus1="SELL" ;}
   
   vA = iMA(Symbol(), TF2, MAFastPeriod, MAFastShift, MAFastMethod, MAFastApply_To, 0);
   vB = iMA(Symbol(), TF2, MASlowPeriod, MASlowShift, MASlowMethod, MASlowApply_To, 0);
   if (vA>vB)
       { BSstatus2="BUY" ;}
   else { BSstatus2="SELL" ;}
   
   vA = iMA(Symbol(), TF3, MAFastPeriod, MAFastShift, MAFastMethod, MAFastApply_To, 0);
   vB = iMA(Symbol(), TF3, MASlowPeriod, MASlowShift, MASlowMethod, MASlowApply_To, 0);
   if (vA>vB)
       { BSstatus3="BUY" ;}
   else { BSstatus3="SELL" ;}
   
   if (BSstatus1=="BUY" && BSstatus2=="BUY" && BSstatus3=="BUY") {BSstatus="BUY"; BS_Color=Color_Up;}
   else if (BSstatus1=="SELL" && BSstatus2=="SELL" && BSstatus3=="SELL") {BSstatus="SELL"; BS_Color=Color_Dn;}
   else {BSstatus="NO TRADE"; BS_Color=NeutralColor;}
   
   OpenStatus=BSstatus; // digunakan pada bagian targeting
   Write("PairName", Jendela, Pojok, jX, jY, Symbol(), 14, "Arial Bold", BS_Color);
   
   vA = iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0);
   Price=DoubleToStr(vA,Digits);
   Write("Price", Jendela, Pojok, jX+10, jY+14, Price, 14, "Arial Bold", BS_Color);

   vB=iHigh(NULL,1440,0); 
   Write("Dist_toHi", Jendela, Pojok, jX+52, jY-10, DoubleToStr((vA-vB)/Point,0), 9, "Arial Bold", Info_Color);
   vC=iLow(NULL,1440,0);
   Write("Dist_toLo", Jendela, Pojok, jX+54, jY+30, DoubleToStr((vA-vC)/Point,0), 9, "Arial Bold", Info_Color);
   
   Write("HiLo", Jendela, Pojok, jX+1, jY+30, DoubleToStr((vB-vC)/Point,0), 9, "Arial Bold", Info_Color);
   
   //--- Daily Av ---
   R1=0; R5=0; R10=0; R20=0; RAvg=0; i=0;
   R1 =  (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   for(i=1;i<=5;i++)   
     R5  = R5  + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=10;i++)
     R10 = R10 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;
   for(i=1;i<=20;i++)
     R20 = R20 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point;

   R5 = R5/5;
   R10 = R10/10;
   R20 = R20/20;
   RAvg  =  (R1+R5+R10+R20)/4;    
   
   Teks_ReRata = (DoubleToStr(RAvg,Digits-4));
   Teks_Rerata_Kemarin = (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point;
   
   //if (Teks_ReRata > Teks_Rerata_Kemarin) {warna_ReRata = Daily_Av_Up_Color;}
   //   else {warna_ReRata = Daily_Av_Dn_Color;}
   Write("DAV", Jendela, Pojok, jX+1, jY-10, Teks_ReRata, 9, "Arial Bold", Info_Color);
   
   //--- Time for Next Candle ---
   vB = (Time[4]-Time[5])-MathMod(CurTime(),Time[4]-Time[5]);
   vA = vB/60;
   vB = (vA-MathFloor(vA))*60;
   vA = MathFloor(vA);
   Teks_Menit = DoubleToStr(vA,0);
   Teks_Detik = DoubleToStr(vB,0);
   Sisa_Waktu=Teks_Menit+":"+Teks_Detik;
   Write("TimeForNextCandle", Jendela, Pojok, jX+44, jY+41, Sisa_Waktu, 9, "Arial Bold", Info_Color);
   
   Write("Spread", Jendela, Pojok, jX+1, jY+41, DoubleToStr((Ask - Bid)/Point, Digits-4), 9, "Arial Bold", Info_Color);
   
   Write("Lin1", Jendela, Pojok, jX+00, jY+56, "____________", 7, "Verdana", Info_Color);
   
   // LOOP
   n=1;
   while (n<=7)
           {
            switch (n)
              {
               case 1: TF = 1440;  posX=jX+58; posY=jY+78;   Ket="D1"; break; 
               case 2: TF =  240;  posX=jX+58; posY=jY+90;   Ket="H4"; break;
               case 3: TF =   60;  posX=jX+58; posY=jY+102;  Ket="H1"; break; 
            
               case 4: TF =   30;  posX=jX+50; posY=jY+126;  Ket="M30"; break; 
               case 5: TF =   15;  posX=jX+50; posY=jY+138;  Ket="M15"; break; 
               case 6: TF =    5;  posX=jX+57; posY=jY+150;  Ket="M5";  break;
               case 7: TF =    1;  posX=jX+57; posY=jY+162;  Ket="M1";  break;
              }//switch
            //BuySeLL  
            vA = iMA(Symbol(), TF, MAFastPeriod, MAFastShift, MAFastMethod, MAFastApply_To, 0);
            vB = iMA(Symbol(), TF, MASlowPeriod, MASlowShift, MASlowMethod, MASlowApply_To, 0);
            if (vA>vB) {BS_Color=Color_Up;}
            else if (vA<vB) {BS_Color=Color_Dn;}
            else {BS_Color=NeutralColor;}
            Write("BuySeLL_"+Ket, Jendela, Pojok, posX, posY, Ket, 9, "Arial Bold", BS_Color);
            
            //TRend
            vA = iMA(Symbol(), TF, tMAFastPeriod, tMAFastShift, tMAFastMethod, tMAFastApply_To, 0);
            vB = iMA(Symbol(), TF, tMASlowPeriod, tMASlowShift, tMASlowMethod, tMASlowApply_To, 0);
            if (vA>vB) {TrendSymbol=UpSymbol; TR_color=Color_Up;}
            else if (vA<vB) {TrendSymbol=DnSymbol; TR_color=Color_Dn;}
            else {TrendSymbol=NtSymbol; TR_color=NeutralColor;}
            Write("TRend_"+Ket, Jendela, Pojok, jX+28, posY, TrendSymbol, 9, "Wingdings 3", TR_color);
            
            vC = iClose( NULL , TF, 0) - iOpen( NULL , TF, 0);
            if ( vC > 0 ) 
                { CandleColor = Color_Up;  CandleSymbol="n"; }
            else if ( vC < 0 )  { CandleColor = Color_Dn; CandleSymbol="n"; }
            else { CandleColor = NeutralColor; CandleSymbol="ª"; }
            Write(("CandleColor_"+Ket), Jendela, Pojok, jX+1, posY, CandleSymbol, 9, "Wingdings", CandleColor);
            
            n++;
           } //end while              
                
   //Write("Lin2", Jendela, Pojok, jX+00, jY+110, "____________", 7, "Verdana", Info_Color);
   Write("Lin2", Jendela, Pojok, jX+00, jY+178, "____________", 7, "Verdana", Info_Color);
   
   // --- TARGETTING ---
   sprd=(Ask - Bid);
   hrg=iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0); //hrg=price
   // Jika status open = BUY
   if (OpenStatus=="BUY")
       {
         TP1=0; TP2=0; TP3=0;
         if (hrg>(r3))                  {TP1=r3+(2*sprd); TP2=r3+(3*sprd); TP3=r3+(4*sprd);}
         else if (hrg==(r3))            {TP1=r3+(2*sprd); TP2=r3+(3*sprd); TP3=r3+(4*sprd);}
         else if ((hrg<r3) && (hrg>m5)) {TP1=r3; TP2=r3+(2*sprd); TP3=r3+(3*sprd);}
         else if ((hrg==m5))            {TP1=r3; TP2=r3+(2*sprd); TP3=r3+(3*sprd);}
         else if ((hrg<m5) && (hrg>r2)) {TP1=m5; TP2=r3; TP3=r3+(2*sprd);}
         else if ((hrg==r2))            {TP1=m5; TP2=r3; TP3=r3+(2*sprd);}
         else if ((hrg<r2) && (hrg>m4)) {TP1=r2; TP2=m5; TP3=r3;}
         else if ((hrg==m4))            {TP1=r2; TP2=m5; TP3=r3;}
         else if ((hrg<m4) && (hrg>r1)) {TP1=m4; TP2=r2; TP3=m5;}
         else if ((hrg==r1))            {TP1=m4; TP2=r2; TP3=m5;}
         else if ((hrg<r1) && (hrg>m3)) {TP1=r1; TP2=m4; TP3=r2;}
         else if ((hrg==m3))            {TP1=r1; TP2=m4; TP3=r2;}
         else if ((hrg<m3) && (hrg>p))  {TP1=m3; TP2=r1; TP3=m4;}
         else if ((hrg==p))             {TP1=m3; TP2=r1; TP3=m4;}
         else if ((hrg<p) && (hrg>m2))  {TP1=p; TP2=m3; TP3=r1;}
         else if ((hrg==m2))            {TP1=p; TP2=m3; TP3=r1;}
         else if ((hrg<m2) && (hrg>s1)) {TP1=m2; TP2=p; TP3=m3;}
         else if ((hrg==s1))            {TP1=m2; TP2=p; TP3=m3;}
         else if ((hrg<s1) && (hrg>m1)) {TP1=s1; TP2=m2; TP3=p;}
         else if ((hrg==m1))            {TP1=s1; TP2=m2; TP3=p;}
         else if ((hrg<m1) && (hrg>s2)) {TP1=m1; TP2=s1; TP3=m2;}
         else if ((hrg==s2))            {TP1=m1; TP2=s1; TP3=m2;}
         else if ((hrg<s2) && (hrg>m0)) {TP1=s2; TP2=m1; TP3=s1;}
         else if ((hrg==m0))            {TP1=s2; TP2=m1; TP3=s1;}
         else if ((hrg<m0) && (hrg>s3)) {TP1=m0; TP2=s2; TP3=m1;}
         else if ((hrg==s3))            {TP1=m0; TP2=s2; TP3=m1;}
         else if ((hrg<s3))             {TP1=s3; TP2=m0; TP3=s2;}
       }
   // Jika status open = SELL
   else
       {
         TP1=0; TP2=0; TP3=0;
         if (hrg>(r3))                  {TP1=r3; TP2=m5; TP3=r2;}
         else if (hrg==(r3))            {TP1=m5; TP2=r2; TP3=m4;}
         else if ((hrg<r3) && (hrg>m5)) {TP1=m5; TP2=r2; TP3=m4;}
         else if ((hrg==m5))            {TP1=r2; TP2=m4; TP3=r1;}
         else if ((hrg<m5) && (hrg>r2)) {TP1=r2; TP2=m4; TP3=r1;}
         else if ((hrg==r2))            {TP1=m4; TP2=r1; TP3=m3;}
         else if ((hrg<r2) && (hrg>m4)) {TP1=m4; TP2=r1; TP3=m3;}
         else if ((hrg==m4))            {TP1=r1; TP2=m3; TP3=p;}
         else if ((hrg<m4) && (hrg>r1)) {TP1=r1; TP2=m3; TP3=p;}
         else if ((hrg==r1))            {TP1=m3; TP2=p; TP3=m2;}
         else if ((hrg<r1) && (hrg>m3)) {TP1=m3; TP2=p; TP3=m2;}
         else if ((hrg==m3))            {TP1=p; TP2=m2; TP3=s1;}
         else if ((hrg<m3) && (hrg>p))  {TP1=p; TP2=m2; TP3=s1;}
         else if ((hrg==p))             {TP1=m2; TP2=s1; TP3=m1;}
         else if ((hrg<p) && (hrg>m2))  {TP1=m2; TP2=s1; TP3=m1;}
         else if ((hrg==m2))            {TP1=s1; TP2=m1; TP3=s2;}
         else if ((hrg<m2) && (hrg>s1)) {TP1=s1; TP2=m1; TP3=s2;}
         else if ((hrg==s1))            {TP1=m1; TP2=s2; TP3=m0;}
         else if ((hrg<s1) && (hrg>m1)) {TP1=m1; TP2=s2; TP3=m0;}
         else if ((hrg==m1))            {TP1=s2; TP2=m0; TP3=s3;}
         else if ((hrg<m1) && (hrg>s2)) {TP1=s2; TP2=m0; TP3=s3;}
         else if ((hrg==s2))            {TP1=m0; TP2=s3; TP3=s3-(2*sprd);}
         else if ((hrg<s2) && (hrg>m0)) {TP1=m0; TP2=s3; TP3=s3-(2*sprd);}
         else if ((hrg==m0))            {TP1=s3; TP2=s3-(2*sprd); TP3=s3-(3*sprd);}
         else if ((hrg<m0) && (hrg>s3)) {TP1=s3; TP2=s3-(2*sprd); TP3=s3-(3*sprd);}
         else if ((hrg==s3))            {TP1=s3-(2*sprd); TP2=s3-(3*sprd); TP3=s3-(4*sprd);}
         else if ((hrg<s3))             {TP1=s3-(2*sprd); TP2=s3-(3*sprd); TP3=s3-(4*sprd);}
       }
   
   Periode = Period(); tPeriode ="";
   switch (Periode)
      {
       case 1     : tPeriode = "M1";  break;
       case 5     : tPeriode = "M5";  break;
       case 15    : tPeriode = "M15"; break;
       
       case 30    : tPeriode = "M30"; break;
       case 60    : tPeriode = "H1";  break;
       case 240   : tPeriode = "H4";  break;
       
       case 1440  : tPeriode = "D1";  break;
       case 10080 : tPeriode = "W1";  break;
       case 43200 : tPeriode = "MN1"; break;
       
      }
   
   if (OpenStatus=="NO TRADE")
      {
       ObjectDelete("TPMS011");
       ObjectDelete("TPMS021");
       ObjectDelete("TPMS031");
       ObjectDelete("TPMS041");
       
       ObjectDelete("TPMS051");
       ObjectDelete("TPMS061");
       ObjectDelete("TPMS071");
       ObjectDelete("TPMS081");
       ObjectDelete("TPMS091");
       ObjectDelete("TPMS0101");

       Write("TPMS011", Jendela, Pojok, tpX, tpY+198, "PLEASE WAIT !!!", 7, "Arial", Info_Color);
       }
   else 
      {
       ObjectDelete("TPMS011");
       Write("TPMS021", Jendela, Pojok, tpX, tpY+198, OpenStatus+" TP1="+ DoubleToStr(TP1, Digits), 9, "Arial Narrow", TP1_color);
       Write("TPMS031", Jendela, Pojok, tpX, tpY+210, OpenStatus+" TP2="+ DoubleToStr(TP2, Digits), 9, "Arial Narrow", TP2_color);
       //Write_SW("TPSU01", 0, 110, 6, Symbol() + " " + tPeriode + " Open Status " + OpenStatus, 10, "Arial", TextColor);
       //Write_SW("TPSU02", 0, 320, 6, "TP1 = " + DoubleToStr(TP1, Digits), 10, "Arial", TP1_color);
       //Write_SW("TPSU03", 0, 410, 6, "TP2 = " + DoubleToStr(TP2, Digits), 10, "Arial", TP2_color);
       //Write_SW("TPSU04", 0, 500, 6, "TP3 = " + DoubleToStr(TP3, Digits), 10, "Arial", TP3_color);
   
       Draw_H_Line("TPMS051",  TP1, TP1_color);
       Label_H_Line("TPMS061", TP1, " TP1 ", TP1_color);
   
       Draw_H_Line("TPMS071",  TP2, TP2_color);
       Label_H_Line("TPMS081", TP2, " TP2 ", TP2_color);
   
       //Draw_H_Line("TPSMS091",  TP3, TP3_color);
       //Label_H_Line("TPMS101", TP3, " TP3 ", TP3_color);
      }
   //Write("OpPos", Jendela, Pojok, jX+00, jY+198, "BUY TP1=8.8888", 7, "Arial", Info_Color);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// Write Procedure
void Write(string LBL, int window, double side, int pos_x, int pos_y, string text, int fontsize, string fontname, color Tcolor=CLR_NONE)
     {
       ObjectCreate(LBL, OBJ_LABEL, window, 0, 0);
       ObjectSet(LBL, OBJPROP_CORNER, side);
       ObjectSet(LBL, OBJPROP_XDISTANCE, pos_x);
       ObjectSet(LBL, OBJPROP_YDISTANCE, pos_y);
       ObjectSetText(LBL,text, fontsize, fontname, Tcolor);
     }
     
  // Draw_H_Line Procedure     
void Draw_H_Line(string Label_name, double Position, color Line_color)
       {
        ObjectDelete(Label_name);
        ObjectCreate(Label_name, OBJ_HLINE,0, CurTime(), Position);
        ObjectSet(Label_name, OBJPROP_COLOR, Line_color);
        ObjectSet(Label_name, OBJPROP_STYLE, STYLE_SOLID);
        ObjectSet(Label_name, OBJPROP_WIDTH, 1);
       }

// Label_H_Line Procedure  
void Label_H_Line (string LabelLine, double Pos_Label, string Text_Label, color Label_color)
          {
            if (ObjectFind(LabelLine) != 0)
               {
                ObjectCreate(LabelLine, OBJ_TEXT, 0, Time[10], Pos_Label);
                ObjectSetText(LabelLine, Text_Label, 9, "Verdana", Label_color);
               }
            else
              {
               ObjectMove(LabelLine, 0, Time[10], Pos_Label);
              }
          }        
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button




 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2.     limit = (Bars - counted_bars) - 1;
       for(i = limit; i >= 0; i--){ 
           if(High[i+1] > LastHigh)  
    When counted is zero, limit is the earliest bar. High[i+1] does not exist.
              How to do your lookbacks correctly #9 - #14 & #19

  3. You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11

  4. ArrayCopyRates(rates, Symbol(), PERIOD_D1);
    

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20

  5. No question, problem asked. No answers necessary.
Reason: