Miscellaneous
0
Views
0
Downloads
0
Favorites
FILTER_ADX_mAMn
//+------------------------------------------------------------------+
//| FILTER_ADX_(AM).mq4 |
//+------------------------------------------------------------------+
#property copyright "Andrey Matvievskiy"
#property link ""
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 4
//---- input parameters
extern int TF=0;
extern int ADXPeriod=14;
extern int PRICE=0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ADX1,pDI1,mDI1;
double ADX2,pDI2,mDI2;
string TimeFrameStr;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Green);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1,Red);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1,Green);
SetIndexBuffer(3,ExtMapBuffer4);
switch(TF)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; TF=0;
}
IndicatorShortName("FILTER ADX(AM) ("+TimeFrameStr+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
int limit = Bars - counted_bars;
if(counted_bars==0) limit--;
for(i=limit; i>=0; i--)
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=0;
ADX1=iADX (NULL,TF,ADXPeriod,PRICE,0,i);
pDI1=iADX (NULL,TF,ADXPeriod,PRICE,1,i);
mDI1=iADX (NULL,TF,ADXPeriod,PRICE,2,i);
ADX2=iADX (NULL,TF,ADXPeriod,PRICE,0,i+1);
pDI2=iADX (NULL,TF,ADXPeriod,PRICE,1,i+1);
mDI2=iADX (NULL,TF,ADXPeriod,PRICE,2,i+1);
if(pDI1<mDI1 && ADX1>ADX2)
{
ExtMapBuffer1[i]=1;
}
if(pDI1>mDI1 && ADX1>ADX2)
{
ExtMapBuffer2[i]=1;
}
if(pDI1<mDI1 && ADX1<ADX2)
{
ExtMapBuffer3[i]=1;
}
if(pDI1>mDI1 && ADX1<ADX2)
{
ExtMapBuffer4[i]=1;
}
}
//----
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
---