Amplitude. Серия №2 =)

 
Для тех, кому интересна амплитуда движения цены продолжаю наработки ( первой серией был скрипт - https://www.mql5.com/en/code ).
Итак, выкладываю на шаровый бета-тестинг =) два индикатора, считающих амплитуду - первый по всей истории, второй - по заданному периоду.

//+------------------------------------------------------------------+
//|                                              	Amplitude_All.mq4 |
//|                                                        komposter |
//|                                      mailto:komposterius@mail.ru |
//+------------------------------------------------------------------+
#property copyright "komposter"
#property link      "mailto:komposterius@mail.ru"

#property indicator_separate_window
#property indicator_minimum 0
#property  indicator_buffers 5
#property  indicator_color1  Red
#property  indicator_color2  Lime
#property  indicator_color3  White
#property  indicator_color4  White
#property  indicator_color5  White

double buf0[]; //High-Low Average
double buf1[]; //Body Average
double buf2[]; //Up_Shadow Average
double buf3[]; //Down_Shadow Average
double buf4[]; //Summ_Shadow Average

int init()
{
	IndicatorShortName( "Amplitude (All history average)   -   " );
	IndicatorDigits ( 2 );

	SetIndexBuffer ( 0 , buf0 );
	SetIndexStyle ( 0 , DRAW_LINE );
	SetIndexDrawBegin ( 0 , 0 );
	SetIndexLabel( 0 , "High-Low");

	SetIndexBuffer ( 1 , buf1 );
	SetIndexStyle ( 1 , DRAW_LINE );
	SetIndexDrawBegin ( 1 , 0 );
	SetIndexLabel( 1 , "Open-Close");

	SetIndexBuffer ( 2 , buf2 );
	SetIndexStyle ( 2 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 2 , 0 );
	SetIndexLabel( 2 , "Up_Shadow");

	SetIndexBuffer ( 3 , buf3 );
	SetIndexStyle ( 3 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 3 , 0 );
	SetIndexLabel( 3 , "Down_Shadow");

	SetIndexBuffer ( 4 , buf4 );
	SetIndexStyle ( 4 , DRAW_LINE );
	SetIndexDrawBegin ( 4 , 0 );
	SetIndexLabel( 4 , "Summ_Shadow");

return(0);
}

int start()
{
	int counted_Bars = IndicatorCounted();
	if ( counted_Bars < 0 ) return(-1);
	if ( counted_Bars > 0 ) counted_Bars -- ;
	int limit = Bars - 1;

	double buf_tmp, buf_tmp1, buf_tmp2, buf_tmp3, buf_tmp4;
	int z, z1, z2, z3, z4;
	
	for ( int i = limit; i >= 0; i -- )
	{
		buf_tmp += ( High[i] - Low[i] ) / Point;
		buf0[i] = buf_tmp / ( Bars - i + z );
		if ( ( High[i] - Low[i] ) / Point == 0 ) z --;

		buf_tmp1 += MathAbs( ( Close[i] - Open[i] ) ) / Point;
		buf1[i] = buf_tmp1 / ( Bars - i + z1 );
		if ( MathAbs( ( Close[i] - Open[i] ) ) / Point  == 0 ) z1 --;

		if ( Close[i] - Open[i] >= 0 )
		{
			buf_tmp2 += ( High[i] - Close[i] ) / Point;
			buf2[i] = buf_tmp2 / ( Bars - i + z2 );
			if ( ( High[i] - Close[i] ) / Point  == 0 ) z2 --;

			buf_tmp3 += ( Open[i] - Low[i] ) / Point;
			buf3[i] = buf_tmp3 / ( Bars - i + z3 );
			if ( ( Open[i] - Low[i] ) / Point  == 0 ) z3 --;
		}
		else
		{
			buf_tmp2 += ( High[i] - Open[i] ) / Point;
			buf2[i] = buf_tmp2 / ( Bars - i + z2 );
			if ( ( High[i] - Open[i] ) / Point  == 0 ) z2 --;

			buf_tmp3 += ( Close[i] - Low[i] ) / Point;
			buf3[i] = buf_tmp3 / ( Bars - i + z3 );
			if ( ( Close[i] - Low[i] ) / Point  == 0 ) z3 --;
		}
		buf4[i] = buf2[i] + buf3[i];
	}

return(0);
}






//+------------------------------------------------------------------+
//|                                              		 Amplitude.mq4 |
//|                                                        komposter |
//|                                      mailto:komposterius@mail.ru |
//+------------------------------------------------------------------+
#property copyright "komposter"
#property link      "mailto:komposterius@mail.ru"

#property indicator_separate_window
#property indicator_minimum 0
#property  indicator_buffers 5
#property  indicator_color1  Red
#property  indicator_color2  Lime
#property  indicator_color3  White
#property  indicator_color4  White
#property  indicator_color5  White

double buf0[]; //High-Low Average
double buf1[]; //Body Average
double buf2[]; //Up_Shadow Average
double buf3[]; //Down_Shadow Average
double buf4[]; //Summ_Shadow Average

extern int AveragePeriod = 13;

int init()
{
	IndicatorShortName( "Amplitude (" + AveragePeriod + " bars average)   -   " );
	IndicatorDigits ( 2 );

	SetIndexBuffer ( 0 , buf0 );
	SetIndexStyle ( 0 , DRAW_LINE  );
	SetIndexDrawBegin ( 0 , AveragePeriod );
	SetIndexLabel( 0 , "High-Low");

	SetIndexBuffer ( 1 , buf1 );
	SetIndexStyle ( 1 , DRAW_LINE  );
	SetIndexDrawBegin ( 1 , AveragePeriod );
	SetIndexLabel( 1 , "Open-Close");

	SetIndexBuffer ( 2 , buf2 );
	SetIndexStyle ( 2 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 2 , AveragePeriod );
	SetIndexLabel( 2 , "Up_Shadow");

	SetIndexBuffer ( 3 , buf3 );
	SetIndexStyle ( 3 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 3 , AveragePeriod );
	SetIndexLabel( 3 , "Down_Shadow");

	SetIndexBuffer ( 4 , buf4 );
	SetIndexStyle ( 4 , DRAW_LINE  );
	SetIndexDrawBegin ( 4 , AveragePeriod );
	SetIndexLabel( 4 , "Summ_Shadow");

return(0);
}

int start()
{
	string _Symbol = Symbol();
	int TimeFrame = Period();

	if ( Bars < AveragePeriod ) { return(-1); }
	int counted_bars = IndicatorCounted();
	if ( counted_bars < 0 ) return(-1);
	if ( counted_bars > 0 ) counted_bars -- ;
	int limit = Bars - AveragePeriod - 1;
	if ( counted_bars > AveragePeriod ) { limit = Bars - counted_bars - 1; }

	double buf_tmp, buf_tmp1, buf_tmp2, buf_tmp3, buf_tmp4;
	int z, z1, z2, z3, z4;
	
	for ( int i = limit; i >= 0; i -- )
	{
		buf_tmp = 0; buf_tmp1 = 0; buf_tmp2 = 0; buf_tmp3 = 0; buf_tmp4 = 0;
		z = 0; z1 = 0; z2 = 0; z3 = 0; z4 = 0;

		for ( int u = i + AveragePeriod; u >= i; u -- )
		{
			buf_tmp += ( High[u] - Low[u] ) / Point;
			if ( ( High[u] - Low[u] ) / Point == 0 ) z --;

			buf_tmp1 += MathAbs( ( Close[u] - Open[u] ) ) / Point;
			if ( MathAbs( ( Close[u] - Open[u] ) ) / Point  == 0 ) z1 --;

			if ( Close[u] - Open[u] >= 0 )
			{
				buf_tmp2 += ( High[u] - Close[u] ) / Point;
				if ( ( High[u] - Close[u] ) / Point  == 0 ) z2 --;

				buf_tmp3 += ( Open[u] - Low[u] ) / Point;
				if ( ( Open[u] - Low[u] ) / Point  == 0 ) z3 --;
			}
			else
			{
				buf_tmp2 += ( High[u] - Open[u] ) / Point;
				if ( ( High[u] - Open[u] ) / Point  == 0 ) z2 --;

				buf_tmp3 += ( Close[u] - Low[u] ) / Point;
				if ( ( Close[u] - Low[u] ) / Point  == 0 ) z3 --;
			}
		}
		buf0[i] = buf_tmp / ( AveragePeriod + z ) ;
		buf1[i] = buf_tmp1 / ( AveragePeriod + z1 ) ;
		buf2[i] = buf_tmp2 / ( AveragePeriod + z2 ) ;
		buf3[i] = buf_tmp3 / ( AveragePeriod + z3 ) ;
		buf4[i] = buf2[i] + buf3[i];
	}

return(0);
}



Предложения по доработке, естественно, принимаются ;)

 
ps(разработчикам): попробовал наложить один индикатор на другой... очень интересная картинка - получается, у каждого индикатора _своя_ шкала... никакого взаимодействия.
у одного индюка - максимум 20, у второго 30 - и они совпадают =)
Так задумано, или недосмотрели?

зызы: если непонятно объяснил - могу скрин выслать...
 
ps(разработчикам): попробовал наложить один индикатор на другой... очень интересная картинка - получается, у каждого индикатора _своя_ шкала... никакого взаимодействия.
у одного индюка - максимум 20, у второго 30 - и они совпадают =)
Так задумано, или недосмотрели?

зызы: если непонятно объяснил - могу скрин выслать...

Так задумано.
 
на шаровый бета-тестинг =)

все обиделись и убежали =)))
хоть посмотрите....
 
на шаровый бета-тестинг =)

все обиделись и убежали =)))
хоть посмотрите....


ДУМАЮ, что ВСЕ СМОТРЯТ.
пошел смотреть :0)
 
ну у меня прям аншлаг какой-то ))) чтоли и себе в код глянуть ;)
Причина обращения: