Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
AD2MA_v03bc_mtf
//+------------------------------------------------------------------+
//| 3-10 2MA of A/D Accumulation2MA.mq4 v.03 |
//| Copyright © 2006, lukas1 |
//| mtf:ForexTSD.com2007 ml ki http://www.alpari-idc.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, lukas1"
#property link "http://www.alpari-idc.ru/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
//#property indicator_color2 Red
//---- buffers
extern int MA1=3;
extern int MA2=10;
extern int MA1mode=0;
extern int MA2mode=0;
extern int TimeFrame = 0;
extern string note_MA_Mode = "SMA0 EMA1 SMMA2 LWMA3";
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
string IndicatorFileName;
double ExtMapBuffer1[];
double SignalBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,SignalBuffer1);
//SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer1);
TimeFrame=MathMax(TimeFrame, Period());
IndicatorShortName("A/D 2MA["+TimeFrame+"] ("+MA1+","+MA2+") Delta");
IndicatorFileName = WindowExpertName();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i, limit;
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
if (TimeFrame != Period())
{
limit = MathMax(limit,TimeFrame/Period());
datetime TimeArray[];
ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
for(i=0,int y=0; i<limit; i++)
{
if(Time[i]<TimeArray[y]) y++;
SignalBuffer1 [i] = iCustom(NULL,TimeFrame,IndicatorFileName,MA1,MA2,MA1mode,MA2mode,0,y);
}
return(0);
}
double diff;
//----
i=Bars-counted_bars-1;
while(i>=0)
{
double high =High[i];
double low =Low[i];
double open =Open[i];
double close=Close[i];
ExtMapBuffer1[i]=(close-low)-(high-close); //2close+high-low
if(ExtMapBuffer1[i]!=0)
{
diff=high-low;
if(0==diff)
ExtMapBuffer1[i]=0;
else
{
ExtMapBuffer1[i]/=diff;
ExtMapBuffer1[i]*=Volume[i];
}
}
if(i<Bars-1) ExtMapBuffer1[i]+=ExtMapBuffer1[i+1];
i--;
}
for(i=limit-1; i>=0; i--)
SignalBuffer1[i]=iMAOnArray(ExtMapBuffer1,0,MA1,0,MA1mode,i)*20
-iMAOnArray(ExtMapBuffer1,0,MA2,0,MA2mode,i)*20;
//----
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
---