Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
AccumulationDistribution
//+------------------------------------------------------------------+
//| Copyright © 2009, Ivan Kornilov|
//| AccumulationDistribution.mq4|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Ivan Kornilov"
#property link "excelf@gmail.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_level1 0
#property indicator_level2 500
#property indicator_level3 -500
#property indicator_level4 2000
#property indicator_level5 -2000
extern int period=377;
extern int periodAccumulation=89;
extern int MAperiod1=55;
extern int MAperiod2=34;
extern bool showValueChenal = false;
extern int history = 3000;
double ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
double ExtBuffer4[];
double ExtBuffer5[];
int init() {
SetIndexStyle(3, DRAW_NONE);
SetIndexBuffer(3, ExtBuffer1);
int type = DRAW_NONE;
if(showValueChenal) {
type = DRAW_HISTOGRAM;
}
SetIndexStyle(2, type, STYLE_SOLID);
SetIndexBuffer(2, ExtBuffer2);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(0, ExtBuffer3);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(1, ExtBuffer4);
int counted_bars = Bars - history + period * 2;
SetIndexDrawBegin(0, counted_bars);
SetIndexDrawBegin(1, counted_bars);
SetIndexDrawBegin(2, counted_bars);
IndicatorShortName("Accumulation/Distribution (" + period + "," + periodAccumulation+ "," + MAperiod1 + "," + MAperiod2 + ")");
SetIndexLabel(1, "Ma Fast");
SetIndexLabel(2, "Ma Slow");
return(0);
}
int start()
{
int limit,i,k;
if(history < limit) {
limit = history;
}
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
if(counted_bars==0) limit-=2+MathMax(periodAccumulation,period);
if(counted_bars < 1){
for(i = 0; i <= limit; i++) {
ExtBuffer1[limit-i] = 0;
}
}
for(i = limit; i >= 0; i--){
double MinVOLUME = Low[iLowest(NULL,0 ,MODE_VOLUME, 288, i)];
double barSize = High[i] - Low[i];
if(barSize == 0 ) {
barSize = Point;
}
double value = (Close[i] - Open[i]) / barSize;
double bayPower = 0;
for(k = i; k < i + periodAccumulation; k++) {
double bpBar = High[k] - Close[k+1] + Close[k] - Low[k];
if(bpBar > 0) {
bayPower+=bpBar;
}
}
double sellPower = 0;
for(k = i; k < i + periodAccumulation; k++) {
double spBar = Close[k+1] - Low[k] + High[k] - Close[k];
if(spBar > 0) {
sellPower+=spBar;
}
}
double temp = MathAbs(bayPower + sellPower);
if(temp == 0) {
temp = Point;
}
double powerTotal = bayPower / temp;
ExtBuffer1[i] = value * (Volume[i] - MinVOLUME) * powerTotal;
}
for(i = 0; i < limit; i++) {
double sum = 0;
for(k = i; k < i + period; k++) {
sum+=ExtBuffer1[k];
}
ExtBuffer2[i]=sum;
}
for(i = 0; i < limit; i++) {
ExtBuffer3[i]=iMAOnArray(ExtBuffer2, Bars, MAperiod1, 0, MODE_EMA, i) * 6;
}
for(i = 0; i < limit; i++) {
ExtBuffer4[i]=iMAOnArray(ExtBuffer3, Bars, MAperiod2, 0, MODE_EMA, 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
---