Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Z1_v1
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int T=1;

double P,ZZ[];
bool Z;
double Max,Min,Top,Bot;
int MaxBar,MinBar,r;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() 
  {
   SetIndexBuffer(0,ZZ);
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexEmptyValue(0,0.0);
   return(0);
  }

int deinit() {return(0);}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start() 
  {
   P=GlobalVariableGet(Symbol()+Period())*Point*10;
   if(P==0) return(0);
   Z=1;
   
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit--;
      
   for(r=limit;r>=0;r--) 
     {
      if(Z) 
        {
         if(High[r]>Max) 
           {
            Max=High[r];
            MaxBar=r;
            Bot=Max-P;
              } else {
            if(Low[r]<Bot && MaxBar-r>=T) 
              {
               Min=Low[r];
               MinBar=r;
               Top=Min+P;
               ZZ[MaxBar]=Max;
               Z=0;
              }
           }
           } else {
         if(Low[r]<Min) 
           {
            Min=Low[r];
            MinBar=r;
            Top=Min+P;
              } else {
            if(High[r]>Top && MinBar-r>=T) 
              {
               Max=High[r];
               MaxBar=r;
               Bot=Max-P;
               ZZ[MinBar]=Min;
               Z=1;
              }
           }
        }
     }
   if(Z>0) {ZZ[MaxBar]=Max;}
   else {ZZ[MinBar]=Min;}
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 ---