Author: Copyright � 2009, Ivan Kornilov. All rights reserved.
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
BarPoints
//+------------------------------------------------------------------+
//|                                   Copyright © 2010, Ivan Kornilov|
//|                                                     BarPoints.mq4|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Ivan Kornilov. All rights reserved."
#property link "excelf@gmail.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Crimson
#property indicator_color2 RoyalBlue

extern double N=0.002;
double shift;

double UpPoints[];
double DownPoints[];
double Trand[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() 
  {
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(0,UpPoints);

   SetIndexStyle(1,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(1,DownPoints);

   SetIndexBuffer(2,Trand);
   IndicatorDigits(Digits+3);

   SetIndexLabel(0,"Point Up");
   SetIndexLabel(1,"Point Down");

   SetIndexDrawBegin(0,1);
   SetIndexDrawBegin(1,1);

   if(Digits==4) 
     {
      shift= N * 10;
        } else {
      shift=N;
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }

double upLevel;
double downLevel;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start() 
  {
   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-=1+1;

   for(int i=limit; i>=0; i--) 
     {
      Trand[i]=Trand[i+1];

      if(Close[i]>High[i+1]+N) 
        {
         Trand[i]=1;
        }

      if(Close[i]<Low[i+1]-N) 
        {
         Trand[i]=-1;
        }

      if(Trand[i]==1) 
        {
         DownPoints[i]=Low[i]-shift;
         UpPoints[i]=EMPTY_VALUE;
           } else if(Trand[i]==-1) {
         UpPoints[i]=High[i]+shift;
         DownPoints[i]=EMPTY_VALUE;
           } else {
         UpPoints[i]=EMPTY_VALUE;
         DownPoints[i]=EMPTY_VALUE;
        }
     }

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