ToClearObjectsByTypeByTime

Author: Copyright © 2017, Nikolay Kositsin
0 Views
0 Downloads
0 Favorites
ToClearObjectsByTypeByTime
ÿþ//+------------------------------------------------------------------+  

//|                                   ToClearObjectsByTypeByTime.mq5 | 

//|                               Copyright © 2017, Nikolay Kositsin | 

//|                              Khabarovsk,   farria@mail.redcom.ru | 

//+------------------------------------------------------------------+  

#property copyright "Copyright © 2017, Nikolay Kositsin"

#property link "farria@mail.redcom.ru"

#property description "!:@8?B >G8I05B 2A5 3@0D8:8 B5@<8=0;0 >B >1J5:B>2 2K1@0==>3> B8?0, :>B>@K5 AB0@H5 :>;8G5AB20 4=59, >?@545;O5<KE C@>2=5< A@010BK20=8O"

#property script_show_confirm //?>B25@645=85 459AB28O A:@8?B0 B@5945@><

#property script_show_inputs //?>:07K20BL 2E>4=K5 ?0@0<5B@K

//+-----------------------------------------------+

//|  %+  " + ! "                    |

//+-----------------------------------------------+

input ENUM_OBJECT OBJ_TYPE=-1;    //"8? C40;O5<KE >1J5:B>2

input uint TimeLevel=10;          //C@>25=L A@010BK20=8O 2 4=OE

//+-----------------------------------------------+



//+------------------------------------------------------------------+ 

//| start function                                                   |

//+------------------------------------------------------------------+

void OnStart()

  {

//---- #40;5=85 2A5E >1J5:B>2 2K1@0==>3> B8?0 A> 2A5E 3@0D8:>2

   int TimeLevelSecond=int(TimeLevel)*60*60*24;

   long currChart=ChartFirst();

   while(currChart>-1)

     {

      int total=ObjectsTotal(currChart,-1,OBJ_TYPE);



      for(int pos=total-1; pos>=0; pos--)

        {

         string name=ObjectName(currChart,pos,-1,OBJ_TYPE);

         datetime time=NULL;

         for(int count=29; count>=0; count--) time=MathMax(datetime(ObjectGetInteger(currChart,name,OBJPROP_TIME,count)),time);

         if(TimeCurrent()-time>TimeLevelSecond) ObjectDelete(currChart,name);

        }

      currChart=ChartNext(currChart); //=0 >A=>20=88 ?@54K4CI53> ?>;CG8< =>2K9 3@0D8: 

      if(currChart<0) break;          //4>AB83;8 :>=F0 A?8A:0 3@0D8:>2      

     }

//----

  }

//+------------------------------------------------------------------+

Comments