Indicators Used
0
Views
0
Downloads
0
Favorites
ATR_x3LHist_mtf
//+------------------------------------------------------------------+
//| ATR.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//|atr x2 http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//2008fxtsd mtf keris f-la
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Maroon
#property indicator_color2 DeepSkyBlue
#property indicator_color3 RoyalBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_level1 0.001
#property indicator_levelcolor SlateGray
//---- input parameters
extern int AtrPeriod1=2;
extern int AtrPeriod2=9;
extern int AtrPeriod3=14;
extern int TimeFrame=0;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
//---- buffers
double AtrBuffer1[];
double AtrBuffer2[];
double AtrBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// IndicatorBuffers(3);
//---- indicator line
SetIndexStyle (2,DRAW_HISTOGRAM);
SetIndexStyle (1,DRAW_LINE);
SetIndexStyle (0,DRAW_LINE);
SetIndexBuffer(2,AtrBuffer1);
SetIndexBuffer(1,AtrBuffer2);
SetIndexBuffer(0,AtrBuffer3);
//---- name for DataWindow and indicator subwindow label
TimeFrame = MathMax (TimeFrame,Period());
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1"; break;
case 5 : TimeFrameStr="M5"; break;
case 15 : TimeFrameStr="M15"; break;
case 30 : TimeFrameStr="M30"; break;
case 60 : TimeFrameStr="H1"; break;
case 240 : TimeFrameStr="H4"; break;
case 1440 : TimeFrameStr="D1"; break;
case 10080 : TimeFrameStr="W1"; break;
case 43200 : TimeFrameStr="MN"; break;
default : TimeFrameStr="TF0";
}
string short_name;
short_name="ATR_("+AtrPeriod1+","+AtrPeriod2+","+AtrPeriod3+") ["+TimeFrameStr+"] ";
IndicatorShortName(short_name);
SetIndexLabel(0,"ATR3 "+short_name);
SetIndexLabel(1,"ATR2 "+short_name);
SetIndexLabel(2,"ATR1 "+short_name);
SetIndexDrawBegin(0,AtrPeriod3);
SetIndexDrawBegin(1,AtrPeriod2);
SetIndexDrawBegin(2,AtrPeriod1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Average True Range |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,shift,limit,y,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
limit=Bars-counted_bars;
limit = MathMax (limit,TimeFrame/Period());
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
AtrBuffer1[i]=iATR(NULL,TimeFrame,AtrPeriod1,y) ;
AtrBuffer2[i]=iATR(NULL,TimeFrame,AtrPeriod2,y);
AtrBuffer3[i]=iATR(NULL,TimeFrame,AtrPeriod3,y);
}
return(0);
}
//+---
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---