Author: Copyright � 2011, Vladimir Hlystov
Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
SL_ATR
//+------------------------------------------------------------------+
//|                                                       SL_ATR.mq4 |
//|                               Copyright © 2011, Vladimir Hlystov |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Vladimir Hlystov"
#property link      "cmillion@narod.ru"
 
#property indicator_chart_window
#property  indicator_buffers 4
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Blue
#property  indicator_color4  Red
 
//+------------------------------------------------------------------+
extern int   Period_ATR     =14;//ïåðèîä ÀÒR
//+------------------------------------------------------------------+
double SLSellMin[],SLBayMin[],SLSellMax[],SLBayMax[];
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
//---- indicator buffers mapping
   SetIndexBuffer(0,SLSellMin);
   SetIndexBuffer(1,SLBayMin);
   SetIndexBuffer(2,SLSellMax);
   SetIndexBuffer(3,SLBayMax);
//---- name for DataWindow and indicator subwindow label
   SetIndexLabel(0,"SL Sell Min");
   SetIndexLabel(1,"SL Bay Min");
   SetIndexLabel(2,"SL Sell Max");
   SetIndexLabel(3,"SL Bay Max");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();      
   if(counted_bars > 0) counted_bars--;
   int limit = Bars-counted_bars;
   double ATR;
   for(int i=0; i<limit; i++) 
   {
      ATR = iATR(Symbol(),0,Period_ATR,i);
      SLBayMin[i]  = NormalizeDouble(Low[i]  + ATR,Digits);
      SLSellMin[i] = NormalizeDouble(High[i] - ATR,Digits);
      SLBayMax[i]  = NormalizeDouble(High[i] + ATR,Digits);
      SLSellMax[i] = NormalizeDouble(Low[i]  - ATR,Digits);
   }
   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 ---