nr4id-atr_761

Author: Rosh
nr4id-atr_761
Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
nr4id-atr_761
//+------------------------------------------------------------------+
//|                                                    NR4ID-ATR.mq4 |
//|                                                             Rosh |
//|                                    http://forexsystems.ru/phpBB/ |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link      "http://forexsystems.ru/phpBB/"
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int       PerATR=1;
extern int       PerNR=4;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   double tempval,minATR,currATR;
   int counted_bars=IndicatorCounted();
//---- 
   if (counted_bars==0) limit=Bars-MathMax(PerNR,PerATR);
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) limit=Bars-counted_bars;
   limit--;
//---- main loop
   for(int i=limit; i>=0; i--)
     {
      tempval=0.0;
      if ((High[i]<High[i+1])&&(Low[i]>Low[i+1]))
        {
         minATR=iATR(NULL,0,PerATR,i);
         for(int cnt=i+1;cnt<i+PerNR;cnt++)
           {
            currATR=iATR(NULL,0,PerATR,cnt);
            if (currATR<minATR) minATR=currATR;
           }
         if (minATR==iATR(NULL,0,PerATR,i))   tempval=(High[i]+Low[i])/2;
        }
      ExtMapBuffer1[i]= tempval;
     }
//----
   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 ---