Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Accumulation2MA_v03b_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 FMA=3;
extern int SMA=10;
extern int TimeFrame = 0;
extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string IndicatorCorrectName = "Accumulation2MA_v03b_mtf";
double ExtMapBuffer1[];
double SignalBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
IndicatorShortName("A/D 2MA["+TimeFrame+"] ("+FMA+","+SMA+") Delta");
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,SignalBuffer1);
//SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(1,ExtMapBuffer1);
if (TimeFrame < Period()) TimeFrame = Period();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Accumulation/Distribution |
//+------------------------------------------------------------------+
int start()
{
int counted_bars1=IndicatorCounted();
int limit1,i1;
if(counted_bars1 < 0) return(-1);
limit1 = Bars-counted_bars1;
if (TimeFrame != Period())
{
limit1 = MathMax(limit1,TimeFrame/Period());
datetime TimeArray[];
ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
for(i1=0,int y=0; i1<limit1; i1++)
{
if(Time[i1]<TimeArray[y]) y++;
SignalBuffer1 [i1] = iCustom(NULL,TimeFrame,IndicatorCorrectName,0,y);
}
return(0);
}
double diff;
int i,limit,counted_bars=IndicatorCounted();
limit=(Bars-counted_bars);
//----
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,FMA,0,MODE_SMA,i)*20
-iMAOnArray(ExtMapBuffer1,0,SMA,0,MODE_SMA,i)*20;
//----
//---- Refresh buffers ++++++++++++++++++++ upgrade by Raff
int TimeFrame; if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
/********************************************************
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
SignalBuffer1[i] = SignalBuffer1[0];
//--
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Raff
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
---