Help with Ichi Alert Indicator - page 2

 
WHRoeder:
I believe it won't be. If you can't sleep 15s and retry (because it is an indicator) you can check if curtime is still zero
iTime will only return zero if there is no history loaded at all.
 

Hi, it still seems to be repeating alerts from the day before.

 

I took a screenshot of yesterday's alerts - and compared it with today's alerts:

 

 

 

Should I maybe not ResetLastError() before doing the check?

 

Thanks,

 

Richard 

 

You could try

   if(TimeDayOfYear(TimeCurrent())!=TimeDayOfYear(iTime(Symbol(),PERIOD_D1,0)))
      return;
 
GumRai:

You could try

 

Thank you! I will give this a try...

 

Would it not produce the same result though? I would imagin that TimeCurrent() and iTime(Symbol(),PERIOD_D1,0) would be the same value always as the client is still updating? Not sure though... will have to test it :)

 

Thanks again.

 

Richard 

 
Well, I would think that TimeCurrent() will be one of the first data items to be available once the terminal connects to the server and as you check IsConnected(), I would hope that this would work.
 
GumRai:
Well, I would think that TimeCurrent() will be one of the first data items to be available once the terminal connects to the server and as you check IsConnected(), I would hope that this would work.
Cool thanks, will give it a try!
 

Different day, same results :)

 

Really not understanding why this is happening. The issue is clearly that the indicator is running before the new tick data is received, but no idea how to stop this ;/ 

 
Please show your updated code
 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window

input string font="Arial";
input color clr=clrBlack;

datetime prevtime,curtime;
int BullishStrength,BearishStrength;
string price,tenkij,chik,kumo;
string pricec,tenkijc,chikc,kumoc;
color green=clrGreen;
color red=clrRed;
color orange=clrOrange;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   ObjectDelete(0,"price_arrow");
   ObjectDelete(0,"tenkij_arrow");
   ObjectDelete(0,"kumo_arrow");
   ObjectDelete(0,"chikou_arrow");

   ObjectDelete(0,"price_label");
   ObjectDelete(0,"tenkij_label");
   ObjectDelete(0,"kumo_label");
   ObjectDelete(0,"chikou_label");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete(0,"price_arrow");
   ObjectDelete(0,"tenkij_arrow");
   ObjectDelete(0,"kumo_arrow");
   ObjectDelete(0,"chikou_arrow");

   ObjectDelete(0,"price_label");
   ObjectDelete(0,"tenkij_label");
   ObjectDelete(0,"kumo_label");
   ObjectDelete(0,"chikou_label");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(IsConnected()==false)
     {
      return(0);
     }
     
   if(TimeDayOfYear(TimeCurrent())!=TimeDayOfYear(iTime(Symbol(),PERIOD_D1,0)))
   {
   return(0);
   }
     
   curtime=iTime(Symbol(),PERIOD_D1,0);
   if(curtime>prevtime)
     {
      ObjectDelete(0,"price_arrow");
      ObjectDelete(0,"tenkij_arrow");
      ObjectDelete(0,"kumo_arrow");
      ObjectDelete(0,"chikou_arrow");

      BullishStrength=0;
      BearishStrength=0;

      //Price above Kumo?
      if(iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1))
        {
         BullishStrength++;
         price=CharToStr(233);
         pricec=green;
        }
      if(iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1))
        {
         BearishStrength++;
         price=CharToStr(234);
         pricec=red;
        }

      if(
         (iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1)) || 
         (iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1))
         )
        {
         price=CharToStr(232);
         pricec=orange;
        }

      //Tenkan-sen & Kijun-sen above Kumo?
      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1))
        {
         BullishStrength++;
         tenkij=CharToStr(233);
         tenkijc=green;
        }
      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1))
        {
         BearishStrength++;
         tenkij=CharToStr(234);
         tenkijc=red;
        }

      if((iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1)) || 
         (iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1)) || 

         (iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1)) || 
         (iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1))
         )

        {
         tenkij=CharToStr(232);
         tenkijc=orange;
        }

      //Kumo is bullish?
      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-25)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-25))
        {
         BullishStrength++;
         kumo=CharToStr(233);
         kumoc=green;
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-25)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-25))
        {
         BearishStrength++;
         kumo=CharToStr(234);
         kumoc=red;
        }

      //Chikou Span above price?
      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,26)>iHigh(Symbol(),PERIOD_D1,26))
        {
         BullishStrength++;
         chik=CharToStr(233);
         chikc=green;
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,26)<iLow(Symbol(),PERIOD_D1,26))
        {
         BearishStrength++;
         chik=CharToStr(234);
         chikc=red;
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,26)>iLow(Symbol(),PERIOD_D1,26) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,26)<iHigh(Symbol(),PERIOD_D1,26))
        {
         chik=CharToStr(232);
         chikc=orange;
        }

      //Create all the labels
      ObjectCreate("price_label",OBJ_LABEL,0,0,0);
      ObjectSet("price_label",OBJPROP_XDISTANCE,10);
      ObjectSet("price_label",OBJPROP_YDISTANCE,20);
      ObjectSetText("price_label","Price to Kumo = ",9,font,clr);

      ObjectCreate("tenkij_label",OBJ_LABEL,0,0,0);
      ObjectSet("tenkij_label",OBJPROP_XDISTANCE,10);
      ObjectSet("tenkij_label",OBJPROP_YDISTANCE,35);
      ObjectSetText("tenkij_label","Tenkan & Kijun to Kumo = ",9,font,clr);

      ObjectCreate("kumo_label",OBJ_LABEL,0,0,0);
      ObjectSet("kumo_label",OBJPROP_XDISTANCE,10);
      ObjectSet("kumo_label",OBJPROP_YDISTANCE,50);
      ObjectSetText("kumo_label","Kumo = ",9,font,clr);

      ObjectCreate("chikou_label",OBJ_LABEL,0,0,0);
      ObjectSet("chikou_label",OBJPROP_XDISTANCE,10);
      ObjectSet("chikou_label",OBJPROP_YDISTANCE,65);
      ObjectSetText("chikou_label","Chikou to Price = ",9,font,clr);

      ObjectCreate("price_arrow",OBJ_LABEL,0,0,0);
      ObjectSet("price_arrow",OBJPROP_XDISTANCE,160);
      ObjectSet("price_arrow",OBJPROP_YDISTANCE,20);
      ObjectSetText("price_arrow",price,9,"Wingdings",pricec);

      ObjectCreate("tenkij_arrow",OBJ_LABEL,0,0,0);
      ObjectSet("tenkij_arrow",OBJPROP_XDISTANCE,160);
      ObjectSet("tenkij_arrow",OBJPROP_YDISTANCE,35);
      ObjectSetText("tenkij_arrow",tenkij,9,"Wingdings",tenkijc);

      ObjectCreate("kumo_arrow",OBJ_LABEL,0,0,0);
      ObjectSet("kumo_arrow",OBJPROP_XDISTANCE,160);
      ObjectSet("kumo_arrow",OBJPROP_YDISTANCE,50);
      ObjectSetText("kumo_arrow",kumo,9,"Wingdings",kumoc);

      ObjectCreate("chikou_arrow",OBJ_LABEL,0,0,0);
      ObjectSet("chikou_arrow",OBJPROP_XDISTANCE,160);
      ObjectSet("chikou_arrow",OBJPROP_YDISTANCE,65);
      ObjectSetText("chikou_arrow",chik,9,"Wingdings",chikc);
      WindowRedraw();

      //BUY
      if(iClose(Symbol(),PERIOD_D1,2)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,2) && 
         iClose(Symbol(),PERIOD_D1,2)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,2) && 
         iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         BullishStrength>=2)
        {
         Alert(Symbol()," | BUY - Kumo Break");
        }

      if(iClose(Symbol(),PERIOD_D1,2)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,2) && 
         iClose(Symbol(),PERIOD_D1,2)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,2) && 
         iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         BullishStrength>=2)
        {
         Alert(Symbol()," | BUY - Kumo Break");
        }

      if(iClose(Symbol(),PERIOD_D1,2)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,2) && 
         iClose(Symbol(),PERIOD_D1,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1) && 
         BullishStrength>=2)
        {
         Alert(Symbol()," | BUY - Kijun Break");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,2)<=iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,2) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1) && 
         BullishStrength>=2)
        {
         Alert(Symbol()," | BUY - Tenkan & Kijun Cross");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-24)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-24) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-25)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-25) && 
         BullishStrength>=2)
        {
         Alert(Symbol()," | BUY - Senkou Cross");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,28)<iHigh(Symbol(),PERIOD_D1,28) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,27)>iHigh(Symbol(),PERIOD_D1,27) && 
         BullishStrength>=2)

        {
         Alert(Symbol()," | BUY - Chikou Break");
        }

      // SELL
      if(iClose(Symbol(),PERIOD_D1,2)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,2) && 
         iClose(Symbol(),PERIOD_D1,2)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,2) && 
         iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,1) && 
         BearishStrength>=2)
        {
         Alert(Symbol()," | SELL - Kumo Break");
        }

      if(iClose(Symbol(),PERIOD_D1,2)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,2) && 
         iClose(Symbol(),PERIOD_D1,2)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,2) && 
         iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,1) && 
         BearishStrength>=2)
        {
         Alert(Symbol()," | SELL - Kumo Break");
        }

      if(iClose(Symbol(),PERIOD_D1,2)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,2) && 
         iClose(Symbol(),PERIOD_D1,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1) && 
         BearishStrength>=2)
        {
         Alert(Symbol()," | SELL - Kijun Break");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,2)>=iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,2) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_TENKANSEN,1)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_KIJUNSEN,1) && 
         BearishStrength>=2)
        {
         Alert(Symbol()," | SELL - Tenkan & Kijun Cross");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-24)>iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-24) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANA,-25)<iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_SENKOUSPANB,-25) && 
         BearishStrength>=2)
        {
         Alert(Symbol()," | SELL - Senkou Cross");
        }

      if(iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,28)>iLow(Symbol(),PERIOD_D1,28) && 
         iIchimoku(Symbol(),PERIOD_D1,9,26,52,MODE_CHINKOUSPAN,27)<iLow(Symbol(),PERIOD_D1,27) && 
         BearishStrength>=2)

        {
         Alert(Symbol()," | SELL - Chikou Break");
        }
      prevtime=iTime(Symbol(),PERIOD_D1,0);
     }
   return(0);
  }
//+------------------------------------------------------------------+          
 
Any ideas? :)