Author: Copyright � 2007, Ilya Filatov
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
cM2_HLC
  //=====================================================================================//
 // HLC (High-Low Channel)                                       (c) Ilya Filatov, 2007 //
//=====================================================================================//

#property copyright "Copyright © 2007, Ilya Filatov"
#property link      "ilya-filatov@ya.ru"

#property indicator_chart_window
#property indicator_buffers 5

#property indicator_color1 LightGray
#property indicator_color2 DarkGray
#property indicator_color3 LightGray
#property indicator_color4 Coral
#property indicator_color5 LightSteelBlue

#property indicator_style1 0
#property indicator_style2 2
#property indicator_style3 0

#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1

extern int p = 24;
extern bool markers = false;

double TL[];
double ML[];
double BL[];
double TM[];
double BM[];


  //=====================================================================================//
 // Èíèöèàëèçàöèÿ                                                                       //
//=====================================================================================//

int init()
{
   if(p<2)
   {
      p = 2;
   }
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,TL);
   SetIndexLabel(0,"HLC-High");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ML);
   SetIndexLabel(1,"HLC-Middle");
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,BL);
   SetIndexLabel(2,"HLC-Low");
   
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexBuffer(3,TM);
   SetIndexArrow(3,159);
   SetIndexLabel(3,"HLC-Top Marker");
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexBuffer(4,BM);
   SetIndexArrow(4,159);
   SetIndexLabel(4,"HLC-Bottom Marker");

   SetIndexDrawBegin(0,p);
   SetIndexDrawBegin(1,p);
   SetIndexDrawBegin(2,p);
   SetIndexDrawBegin(3,p);
   SetIndexDrawBegin(4,p);

   string short_name = "HLC (" + p + ")";
   IndicatorShortName(short_name);
   Comment(short_name);
}


  //=====================================================================================//
 // Äåèíèöèàëèçàöèÿ                                                                     //
//=====================================================================================//

int deinit()
{
   Comment("");
}


  //=====================================================================================//
 // Çàïóñê                                                                              //
//=====================================================================================//

int start()
{
   for(int i=Bars-IndicatorCounted()-1; i>=0; i--)
   {
      TL[i] = High[iHighest(NULL,0,MODE_HIGH,p,i)];
      BL[i] = Low[iLowest(NULL,0,MODE_LOW,p,i)];

      if(markers==true)
      {
         if(High[i]==High[Highest(NULL,0,MODE_HIGH,p,i)])
         {
            TM[i] = High[i];
         }
         if(Low[i]==Low[Lowest(NULL,0,MODE_LOW,p,i)])
         {
            BM[i] = Low[i];
         }
      }
      ML[i] = (High[iHighest(NULL,0,MODE_HIGH,p,i)] + Low[iLowest(NULL,0,MODE_LOW,p,i)]) / 2;
   }
}

//=====================================================================================//

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