DayColorSquare

Author: Alex-W-
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains the lowest prices of each bar
0 Views
0 Downloads
0 Favorites
DayColorSquare
//+------------------------------------------------------------------+
//|                                               DayColorSquare.mq4 |
//|                                                          Alex-W- |
//|                                                    Alex-W-@bk.ru |
//+------------------------------------------------------------------+
#property copyright "Alex-W-"
#property link      "Alex-W-@bk.ru"

#property indicator_chart_window
//--- input parameters
extern bool       Period_5M   = false;                   // Âûáîð ñòàðøåãî ïåðèîäà ôîðìèðîâàíèå öåí êîòîðîãî õîòèì îòñëåäèòü íà áîëåå íèçêîì òàéìôðåéìå.
extern bool       Period_15M  = false;
extern bool       Period_30M  = false;
extern bool       Period_1H   = false;
extern bool       Period_4H   = false;
extern bool       Period_D    = false;
extern bool       Period_W    = false;
extern bool       Period_M    = false;
extern color      Color_1     = PeachPuff;               // Öâåòà êâàäðàòîâ
extern color      Color_2     = Gainsboro;
extern int        HistoryDay = 100;                      // Íà ñêîëüêî äíåé ïî èñòîðèè ðàçìå÷àòü.
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll(0, OBJ_RECTANGLE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int  DayBars, dx, OpenBarTime, CloseBarTime, ToDay, ToMonth, ToYear, per=0, numDay, pt, cx=0;
   double HightPrice, LowPrice;
   color c;
   string nameDay[7];
   bool interrupt = true;

//----

   nameDay[0] = "Âñ";
   nameDay[1] = "Ïí";
   nameDay[2] = "Âò";
   nameDay[3] = "Ñð";
   nameDay[4] = "×ò";
   nameDay[5] = "Ïò";
   nameDay[6] = "Ñá";
   
   dx = 0;
   
   if(Period_5M) {per = PERIOD_M5; cx++;}
   if(Period_15M) {per = PERIOD_M15; cx++;}
   if(Period_30M) {per = PERIOD_M30; cx++;}
   if(Period_1H) {per = PERIOD_H1; cx++;}
   if(Period_4H) {per = PERIOD_H4; cx++;}
   if(Period_D) {per = PERIOD_D1; cx++;}
   if(Period_W) {per = PERIOD_W1; cx++;}
   if(Period_M) {per = PERIOD_MN1; cx++;}

   if(per == 0){
      Print("*** Íå âûáðàí èññëåäóåìûé ïåðèîä. ***");
      interrupt = false;
   } else {
      if(cx > 1){
         Print("*** Îøèáêà, âûáðàíî áîëåå 1 ïåðèîäà. ***");
         interrupt = false;
      } else {
         if(Period() >= per) {
            Print("*** Ïåðèîä òåêóùåãî ãðàôèêà äîëæåí áûòü ìåíüøå èññëåäóåìîãî. ***");
            interrupt = false;
         }
      }
   }

   if(interrupt){
      while (dx <= HistoryDay)
      {
         OpenBarTime =  iTime(NULL, per, dx);         // Âîçâðàùàåò âðåìÿ îòêðûòèÿ áàðà.
         CloseBarTime = OpenBarTime +(per * 60);      // Ïîëó÷àåì âðåìÿ çàêðûòèÿ áàðà.
         HightPrice = iHigh(NULL, per, dx);           // Âîçâðàùàåò ìàêñèìàëüíóþ öåíó áàðà
         LowPrice = iLow(NULL, per, dx);              // Âîçâðàùàåò ìèíèìàëüíóþ öåíó áàðà
      
         if ((dx % 2) == 0) c = Color_1;
         else c = Color_2;
      
         ToDay = TimeDay (OpenBarTime);         // âîçâðàùàåò äåíü ìåñÿöà
         ToMonth = TimeMonth(OpenBarTime);      // íîìåð ìåñÿöà â ãîäó
         ToYear = TimeYear(OpenBarTime);        // ãîä
         numDay = TimeDayOfWeek(OpenBarTime);   // Âîçâðàùàåò íîìåð äíÿ íåäåëè
         pt = (HightPrice - LowPrice) / Point;  // Äâèæåíèå öåíû
      
         ObjectCreate ("Squard_"+dx, OBJ_RECTANGLE, 0, OpenBarTime, HightPrice, CloseBarTime, LowPrice);
         ObjectSet ("Squard_"+dx, OBJPROP_COLOR, c);
         ObjectSetText ("Squard_"+dx, ToDay + "." + ToMonth + "." + ToYear + " " + nameDay[numDay]+"  "+ pt+" ï", 8, "Times New Roman", Green);
       
      
         dx++;
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---