Author: Denis Orlov
Instrument
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
Instrument
//+------------------------------------------------------------------+
//|                                                   Instrument.mq4 |
//|                                                      Denis Orlov |
//|                                    http://denis-or-love.narod.ru |
/*

Äåíèñ Îðëîâ
http://denis-or-love.narod.ru

***
Âñå ìîè èíäèêàòîðû:
http://codebase.mql4.com/ru/author/denis_orlov
***
ÏÎËÜÇÓÉÒÅÑÜ È ÏÐÎÖÂÅÒÀÉÒÅ!

Sorry for my English!)

Denis Orlov
http://denis-or-love.narod.ru
***
All my indicators:

http://codebase.mql4.com/author/denis_orlov

*/
//+------------------------------------------------------------------+
#property copyright "Denis Orlov"
#property link      "http://denis-or-love.narod.ru"

#property indicator_chart_window
#property indicator_buffers 4

#property indicator_color1 DarkTurquoise
#property indicator_color2 DarkBlue
#property indicator_color3 DarkTurquoise
#property indicator_color4 DarkBlue

double Line1[], Line2[], Line3[], Line4[];

extern string Instrument="";
extern int TimeFrame=0;
extern int VertShift=0;
extern int HorizShift=0;
extern int History=1000;
extern bool GoldColor=False;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,0,3);
   SetIndexBuffer(0,Line1);
   SetIndexShift( 0, HorizShift); 
     
   SetIndexStyle(1,DRAW_HISTOGRAM,0,3);
   SetIndexBuffer(1,Line2);  
   SetIndexShift( 1, HorizShift);
   
   SetIndexStyle(2,DRAW_HISTOGRAM,0,1);
   SetIndexBuffer(2,Line3);
   SetIndexShift( 2, HorizShift);
   
   SetIndexStyle(3,DRAW_HISTOGRAM,0,1);
   SetIndexBuffer(3,Line4);
   SetIndexShift( 3, HorizShift);
   
      if(GoldColor)
      {
         SetIndexStyle(0,DRAW_HISTOGRAM,0,3,Yellow);
         SetIndexStyle(1,DRAW_HISTOGRAM,0,3,Orange);
         SetIndexStyle(2,DRAW_HISTOGRAM,0,1,Yellow);
         SetIndexStyle(3,DRAW_HISTOGRAM,0,1,Orange);
      }
      
    if (Instrument=="") Instrument=Symbol();
    if (TimeFrame==0) TimeFrame=Period();
    IndicatorShortName(Instrument+" "+PeriodToStr(TimeFrame)+": shift "+VertShift);  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      int    Counted_bars=IndicatorCounted();
//----
      int      i=Bars-Counted_bars-1;           // Èíäåêñ ïåðâîãî íåïîñ÷èòàííîãî  
     if (History>0&&i>History)                 // Åñëè ìíîãî áàðîâ òî ..      
       i=History; 
       
      while(i>=0)                      // Öèêë ïî íåïîñ÷èòàííûì áàðàì     
      {
      
             double
           H=iHigh(Instrument, TimeFrame,i),
           L=iLow(Instrument, TimeFrame,i),
           O=iOpen(Instrument,TimeFrame,i),
           C=iClose(Instrument, TimeFrame,i);
           
           if(C>O)
            {
               Line1[i]=C+VertShift*Point; Line2[i]=O+VertShift*Point;
               Line3[i]=H+VertShift*Point; Line4[i]=L+VertShift*Point; 
            }
            else
            if(C<O)
            {
               Line1[i]=C+VertShift*Point; Line2[i]=O+VertShift*Point;
               Line3[i]=L+VertShift*Point; Line4[i]=H+VertShift*Point; 
            }
            else
            if(C==O)
            {
               Line1[i]=O+VertShift*Point; Line2[i]=Line1[i]+0.01*Point;
               Line3[i]=L+VertShift*Point; Line4[i]=H+VertShift*Point; 
            }
      
      
      i--;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
string PeriodToStr(int Per)
   {
      switch(Per)                 // Ðàñ÷¸ò êîýôôèöèåíòîâ äëÿ..     
      {                              // .. ðàçëè÷íûõ ÒÔ      
      case     1: return("M1");  // Òàéìôðåéì Ì1      
      case     5: return("M5");  // Òàéìôðåéì Ì5      
      case    15: return("M15");  // Òàéìôðåéì Ì15      
      case    30: return("M30");  // Òàéìôðåéì Ì30      
      case    60: return("H1");  // Òàéìôðåéì H1      
      case   240: return("H4");  // Òàéìôðåéì H4      
      case  1440: return("D1");  // Òàéìôðåéì D1      
      case 10080: return("W1");  // Òàéìôðåéì W1      
      case 43200: return("ÌN");  // Òàéìôðåéì ÌN     
      }
   }
///=======================

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