//+---------------------------------------------------------------------+
//| Aggressiveness2.mq4 |
//| Copyright � Trofimov 2009 |
//+---------------------------------------------------------------------+
//| �������������2 |
//| |
//| ��������: ���������� ������� ������� �������� ���������� |
//| �� ���� ����� � ������� �� ��������� nDays ����. |
//| ��������� ������� ��������� ������ �� ����������� ������, ��� D! |
//| |
//| ��������� ����� ����������� ��������� ������� �����������, 2009 |
//+---------------------------------------------------------------------+
#property copyright "Copyright � Evgeniy Trofimov, 2009"
#property link "http://TrofimovVBA.narod.ru/"
//---- �������� ����������
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 MidnightBlue
#property indicator_width1 1
#property indicator_color2 Maroon
#property indicator_width2 1
//---- �������� ���������
extern int nDays=22; // - ���������� ������������� ����
extern int Future=3; // - �� ������� ������ ����� ����������
double Buff_line1[];
double Buff_line2[];
double CUp, CDn;
int CandlesInDay;
//+------------------------------------------------------------------+
//| ������� ������������� ���������� |
//+------------------------------------------------------------------+
int init() {
IndicatorBuffers(2);
IndicatorDigits(0);
//---- ��������� ��������� (��������� ���������� ����)
//SetIndexDrawBegin(0,MyPeriod);
//---- x �������������� ������ ����������
SetIndexBuffer(0,Buff_line1);
SetIndexBuffer(1,Buff_line2);
SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY);
SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, EMPTY);
SetIndexShift(0, Future);
SetIndexShift(1, Future);
SetIndexLabel(0, "Up");
SetIndexLabel(1, "Dn");
//---- ��� ���������� � ��������� ��� �����
IndicatorShortName("Aggressiveness2("+nDays+", "+Future+")");
switch(Period()){
case PERIOD_M1: CandlesInDay=1440; break;
case PERIOD_M5: CandlesInDay=288; break;
case PERIOD_M15: CandlesInDay=96; break;
case PERIOD_M30: CandlesInDay=48; break;
case PERIOD_H1: CandlesInDay=24; break;
case PERIOD_H4: CandlesInDay=6; break;
default: CandlesInDay=1; break;
}
return(0);
}//init()
//+------------------------------------------------------------------+
//| ������� ���������� |
//+------------------------------------------------------------------+
int start() {
int BeginBar;
int counted_bars=IndicatorCounted(); // ����� ����������� ����
if(counted_bars<0) return(-1); //---- ������� ��������� ������
//---- ����� ���� �� ��������� � ������� ������ �������� �� �����
BeginBar=Bars-counted_bars-1;
//---- �������� ����������
double B;
for(int t=BeginBar; t>=0; t--) {
LengthCandle(t-Future);
Buff_line1[t]=CUp;
Buff_line2[t]=-CDn;
}//Next t
return(0);
} //start()
//+------------------------------------------------------------------+
int LengthCandle(int CurrenCandle) {
int i, DayUp, DayDn;
CUp=0; CDn=0;
for(i=CurrenCandle+nDays*CandlesInDay;i>CurrenCandle;i=i-CandlesInDay) { // - ����� �����
if(Open[i]<Close[i]) {
CUp=CUp+(Close[i]-Open[i])/Point;
DayUp++;
} else {
CDn=CDn+(Open[i]-Close[i])/Point;
DayDn++;
}
}//Next i
//CDn=CDn/nDays;
//CUp=CUp/nDays;
if(DayUp!=0) CUp=CUp/DayUp;
if(DayDn!=0) CDn=CDn/DayDn;
return(0);
} //LengthCandle()