Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
ATR_Ratio_v2
//+------------------------------------------------------------------+
//| ATR_Ratio_v2.mq4 |
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Purple
#property indicator_level1 1
#property indicator_minimum 0.5
#property indicator_maximum 1.5
//---- indicator parameters
extern int FastATR_Period = 5;
extern int SlowATR_Period = 14;
extern int ShowBars = 500;
//---- indicator buffers
double ATRFast[],ATRSlow[];
double ATR_Ratio_Buffer[];
double ATRFastDev[],ATRSlowDev[];
double ATRDev_Ratio_Buffer[];
int draw_begin0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- additional buffer used for counting.
IndicatorBuffers(6);
//---- drawing settings
draw_begin0 = SlowATR_Period;
SetIndexEmptyValue(0,0.0000);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,ATR_Ratio_Buffer);
SetIndexLabel(0,"ATRFast/ATRSlow");
SetIndexDrawBegin(0,draw_begin0);
SetIndexEmptyValue(1,0.0000);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(1,ATRDev_Ratio_Buffer);
SetIndexLabel(1,"ATRFastDev/ATRSlowDev");
SetIndexDrawBegin(1,draw_begin0);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(2,ATRFast);
SetIndexStyle(3,DRAW_NONE);
SetIndexBuffer(3,ATRSlow);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(4,ATRFastDev);
SetIndexStyle(5,DRAW_NONE);
SetIndexBuffer(5,ATRSlowDev);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ATR_Ratio_v2");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start() {
int limit,i,shift;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<1)
for(i=1;i<=draw_begin0;i++)
ATRDev_Ratio_Buffer[Bars-i]=0; ATR_Ratio_Buffer[Bars-i]=0;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//limit=Bars-counted_bars;
limit = ShowBars;
if (ShowBars >= Bars) limit = Bars - 1;
//-----------------------------------------------------------------------------------------------------------------
//---- preadxbuffer
for(i=0; i<limit; i++) {
ATRFast[i]=iATR(Symbol(),0,FastATR_Period,i);
ATRSlow[i]=iATR(Symbol(),0,SlowATR_Period,i);
if ( ATRSlow[i]!=0 )
ATR_Ratio_Buffer[i] = ATRFast[i]/ATRSlow[i];
}
//---- finaladxbuffer
for(i=0; i<limit; i++) {
ATRFastDev[i]= iStdDevOnArray(ATRFast,0,5,0,MODE_LWMA,i);
ATRSlowDev[i]= iStdDevOnArray(ATRSlow,0,5,0,MODE_LWMA,i);
if ( ATRSlowDev[i]!=0 )
ATRDev_Ratio_Buffer[i]=ATRFastDev[i]/ATRSlowDev[i];
}
//-----------------------------------------------------------------------------------------------------------------
//---- done
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
---