Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Oscillator of ATR
//+------------------------------------------------------------------+
//| Oscillator of ATR.mq4 |
//| vasbsm@mail.ru |
//| |
//+------------------------------------------------------------------+
#property copyright "vasbsm@mail.ru"
#property link ""
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 3
//---- input parameters
extern int FirstAtrPeriod=138;
extern int SecondAtrPeriod=94;
extern int TypeMA=0;
//-----------------------
double OscAtrBuffer[];
double TempBuffer[];
//------------------------
int init()
{
string short_name;
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,OscAtrBuffer);
SetIndexBuffer(1,TempBuffer);
short_name="Oscillator of ATR("+FirstAtrPeriod+","+SecondAtrPeriod+","+"Type of MA="+TypeMA+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexDrawBegin(0,FirstAtrPeriod);
return(0);
}
//---------------------------------------------
int start()
{
int counted_bars=IndicatorCounted(),i;
if(Bars<=FirstAtrPeriod) return(0);
if(counted_bars<1)
for(i=1;i<=FirstAtrPeriod;i++) OscAtrBuffer[Bars-i]=0.0;
//----------------
i=Bars-counted_bars-1;
while(i>=0)
{
double high=High[i];
double low =Low[i];
if(i==Bars-1) TempBuffer[i]=high-low;
else
{
double prevclose=Close[i+1];
TempBuffer[i]=1000*(MathMax(high,prevclose)-MathMin(low,prevclose));
}
i--;
}
//---------------
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(i=0; i<limit; i++)
OscAtrBuffer[i]=iMAOnArray(TempBuffer,Bars,FirstAtrPeriod,0,TypeMA,i)-iMAOnArray(TempBuffer,Bars,SecondAtrPeriod,0,TypeMA,i);
//---------------
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
---