Time of Inactivity

0 Views
0 Downloads
0 Favorites
Time of Inactivity
ÿþ//+------------------------------------------------------------------+

//|                                           Time of Inactivity.mq4 |

//|                        Copyright 2022, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

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

#property indicator_chart_window

#property strict

extern int No_of_days_to_colour = 20;



extern int   HOUR_BEGIN                = 6; //Hour to draw the lines

extern int   MINUTE_BEGIN              = 30; //Minute to draw the lines

extern int   HOUR_END                = 22; //Hour to draw the lines

extern int   MINUTE_END              = 45; //Minute to draw the lines

extern color Rectangle_Color          = clrDimGray; //Color of the lines



double Days[][6];

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

ArrayCopyRates(Days,Symbol(),PERIOD_D1);

//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//----

   for (int i = No_of_days_to_colour; i >= 0; i--) {

      ObjectDelete("RECT_A"+i);

       ObjectDelete("RECT_B"+i);

   }

//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

//---

   

   for (int i = 0; i <= No_of_days_to_colour; i++) {

   

   if((HOUR_END*100+MINUTE_END)>(HOUR_BEGIN*100+MINUTE_BEGIN)){

 ObjectCreate("RECT_A"+i,OBJ_RECTANGLE,0,Days[i][0]+3600*HOUR_END+60*MINUTE_END,0,Days[i][0]+86400,100000);

         ObjectSet("RECT_A"+i,OBJPROP_COLOR,Rectangle_Color);   

 ObjectCreate("RECT_B"+i,OBJ_RECTANGLE,0,Days[i][0],0,Days[i][0]+3600*HOUR_BEGIN+60*MINUTE_BEGIN,100000);

         ObjectSet("RECT_B"+i,OBJPROP_COLOR,Rectangle_Color);}

         

      else{

      ObjectCreate("RECT_C"+i,OBJ_RECTANGLE,0,Days[i][0]+3600*HOUR_END+60*MINUTE_END,0,Days[i][0]+3600*HOUR_BEGIN+60*MINUTE_BEGIN,100000);

         ObjectSet("RECT_C"+i,OBJPROP_COLOR,Rectangle_Color);

      

      }     

   }



   

//----

   return(0);

  }

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

Comments