Download MetaTrader 5

Deleting Seleted Objectes

To add comments, please log in or register
Sameer
808
Sameer  

Hi all,

I've converted the code from mt4 to mt5 using some basic scripts, however, its not functioning as i want. 

I've managed to clear up all the errors, however, that is not enough !

the code doesn't read out the true or false values set at input level, and deletes everything, 

Kindly suggest a fix. thanks in advance.


here is the code,

//+------------------------------------------------------------------+
//|                                                  CLEAR_CHART.mq5 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright " "
#property link      " "
#property script_show_inputs


input string delete_on_Partial_name="";

input bool Vertical_line=true;
input bool Horisontal_line=false;
input bool Trend_line=true;
input bool Trendbyangle_line=true;
input bool Regression_chanel=true;
input bool _chanel=false;
input bool StdDev_chanel=true;
input bool Gann_line=true;
input bool GannFan=true;
input bool GannGrid=true;
input bool FIBO=true;
input bool FIBO_times=true;
input bool FIBO_fan=true;
input bool FIBO_arc=true;
input bool Expansion=true;
input bool FIBO_channel=true;
input bool Restangle=true;
input bool Triangle=true;
input bool Ellipse=true;
input bool PitchFork=true;
input bool Cycles=true;
input bool Text=true;
input bool Arrow=true;
input bool Label=true;

bool u[24];
int OnInit()
{
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

u[0]=Vertical_line; u[1]=Horisontal_line; u[2]=Trend_line; u[3]=Trendbyangle_line;
u[4]=Regression_chanel; u[5]=_chanel; u[6]=StdDev_chanel; u[7]=Gann_line;
u[8]=GannFan; u[9]=GannGrid; u[10]=FIBO; u[11]=FIBO_times;
u[12]=FIBO_fan; u[13]=FIBO_arc; u[14]=Expansion; u[15]=FIBO_channel;
u[16]=Restangle; u[17]=Triangle; u[18]=Ellipse; u[19]=PitchFork;
u[20]=Cycles; u[21]=Text; u[22]=Arrow; u[23]=Label; 
 return(0);

}

int OnStart()
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

//----
   string s; 
   int j,k,_type,i;
   k=ObjectsTotal(0,-1);
   bool w1=false;
   
   for(j=0;j<24;j++) if(u[j]) w1=true;
      if(!w1&&StringLen(delete_on_Partial_name)==0)
         for ( i=k-1;i>=0; i--) //delte ALL
         {
         s=ObjectName(0,i);
         ObjectDelete(0,s);
         }else
    {
         if(StringLen(delete_on_Partial_name)!=0) 
            for (i=k-1;i>=0; i--)//delete partial 
            {
            s=ObjectName(0,i);
            if(StringFind(s,delete_on_Partial_name,0)>=0)ObjectDelete(0,s);
            }
   
      if(w1)
         for (i=k-1;i>=0; i--)//delete by type
         {
         s=ObjectName(0,i);
         _type=ObjectGetInteger(0,s,OBJPROP_TYPE);
         if(_type>=0&&_type<=23)
            {
            for(j=0;j<24;j++)
            if(u[_type]) ObjectDelete(0,s);
            }
         }
      }//else
   
   return(0);
  }



To add comments, please log in or register