i-DayOfWeek

Author: ��� ����� �. aka KimIV
i-DayOfWeek
Price Data Components
Series array that contains the highest prices of each bar
0 Views
0 Downloads
0 Favorites
i-DayOfWeek
//+------------------------------------------------------------------+
//|                                                  i-DayOfWeek.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 13.10.2005  Ïîêàçûâàåò âûáðàííûé äåíü íåäåëè                     |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Salmon
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int NumberDayOfWeek=1;   // Íîìåð äíÿ íåäåëè
extern int NumberOfBars   =0;   // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
int ArrowInterval, prevDay;
//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double UpLine[];
double DnLine[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  void init() 
  {
   SetIndexBuffer(0, UpLine);
   SetIndexStyle (0, DRAW_ARROW);
   SetIndexArrow (0, 159);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexBuffer(1, DnLine);
   SetIndexStyle (1, DRAW_ARROW);
   SetIndexArrow (1, 159);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   ArrowInterval=GetArrowInterval();
   Comment(NameDayOfWeek(NumberDayOfWeek));
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
  void deinit() 
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  void start() 
  {
   double dMax, dMin;
   int    loopbegin, nsb, shift;
//----
   if (NumberOfBars==0) loopbegin=Bars - 1;
   else loopbegin=NumberOfBars - 1;
     for(shift=0; shift<=loopbegin; shift++) 
     {
        if (prevDay!=TimeDay(Time[shift])) 
        {
         nsb=iBarShift(NULL, PERIOD_D1, Time[shift]);
         dMax=iHigh(NULL, PERIOD_D1, nsb)+ArrowInterval*Point;
         dMin=iLow (NULL, PERIOD_D1, nsb)-ArrowInterval*Point;
        }
        if (TimeDayOfWeek(Time[shift])==NumberDayOfWeek) 
        {
         UpLine[shift]=dMax;
         DnLine[shift]=dMin;
        }
      prevDay=TimeDay(Time[shift]);
     }
  }
//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé              |
//+------------------------------------------------------------------+
  int GetArrowInterval() 
  {
   int p=Period();
     switch(p) 
     {
         case 1:     return(5);
         case 5:     return(7);
         case 15:    return(10);
         case 30:    return(15);
         case 60:    return(20);
         case 240:   return(30);
         case 1440:  return(40);
         case 10080: return(150);
         case 43200: return(250);
        }
     }
//+------------------------------------------------------------------+
//| Âîçâðàùàåò íàèìåíîâàíèå äíÿ íåäåëè                               |
//+------------------------------------------------------------------+
           string NameDayOfWeek(int ndw) 
           {
            if (ndw==0) return("Âîñêðåñåíüå");
            if (ndw==1) return("Ïîíåäåëüíèê");
            if (ndw==2) return("Âòîðíèê");
            if (ndw==3) return("Ñðåäà");
            if (ndw==4) return("×åòâåðã");
            if (ndw==5) return("Ïÿòíèöà");
            if (ndw==6) return("Ñóááîòà");
           }
//+------------------------------------------------------------------+

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 ---