CurrencyDeviation-V1b04





//---------------------------------------------------------------------
//	Îáçîð ðûíêà.
//	Ïîçâîëÿåò â îäíîì ýêðàíå âèäåòü äâèæåíèå äî 16 èíñòðóìåíòîâ
//	ïî 4 òàéì-ôðåéìàì.
//---------------------------------------------------------------------

//---------------------------------------------------------------------
//	Èñòîðèÿ âåðñèé:
//---------------------------------------------------------------------
//	30.09.2009ã. - V1b01
//	 - íà÷àëüíàÿ âåðñèÿ;
//
//	01.10.2009ã. - V1b02
//	 - èñïðàâëåíà îøèáêà ïðè èçìåíåíèè â ñïèñêå ÒÔ ( íå óäàëÿëèñü îáúåêòû
//		 äëÿ ñòàðûõ ÒÔ );
//	 - ñäåëàíî îãðàíè÷åíèå ÷èñëà ÒÔ ( äî 4 ) è ÷èñëà âàëþò ( äî 16 ),
//		 îäíîâðåìåííî îòîáðàæàåìûõ â îêíå;
//
//	02.10.2009ã. - V1b03
//	 - äîáàâëåí âûâîä äîïîëíèòåëüíûõ ïîëåé ( ñïðýä, ñòîï-ëåâåë, äíåâíîé
//		 äèàïàçîí, ñðåäíèé äíåâíîé äèàïàçîí );
//
//	13.10.2009ã. - V1b04
//	 - ñäåëàí âûâîä öèôðîâûõ ïîëåé â ãëàâíîå îêíî âìåñòî äîïîëíèòåëüíîãî;
//---------------------------------------------------------------------

//---------------------------------------------------------------------
#property copyright "Copyright © 2009, Dima S."
#property link      "ddd003@mail.ru"
//---------------------------------------------------------------------

//---------------------------------------------------------------------
////#property indicator_chart_window
#property indicator_separate_window
//---------------------------------------------------------------------

//---------------------------------------------------------------------
#property  indicator_minimum	-3.0
#property  indicator_maximum	+3.0
//---------------------------------------------------------------------
#property  indicator_level1		-1.5
#property  indicator_level2		-1.0
#property  indicator_level3		-0.5
#property  indicator_level4		+1.5
#property  indicator_level5		+1.0
#property  indicator_level6		+0.5
#property  indicator_level7		+0.0
//---------------------------------------------------------------------

//---------------------------------------------------------------------
#define INDICATOR_NAME					"CurrencyDeviation"
#define INDICATOR_VERSION				"V1"
#define INDICATOR_SUB_VERSION		"b04"
//---------------------------------------------------------------------

//---------------------------------------------------------------------
#define TREND_UP					1
#define TREND_DN				 -1
#define NO_TREND					0
//---------------------------------------------------------------------

//---------------------------------------------------------------------
//	Âíåøíèå ïîäêëþ÷àåìûå ìîäóëè:
//---------------------------------------------------------------------
#include <stdlib.mqh>														// ñòàíäàðòíàÿ áèáëèîòåêà
#include <lib_display.mq4>											// áèáëèîòåêà äëÿ âûâîäà äàííûõ íà ýêðàí

//---------------------------------------------------------------------
//	Ãëîáàëüíûå ïåðåìåííûå:
//---------------------------------------------------------------------
extern string	CurrencyList = "EURUSD; GBPUSD; AUDUSD; NZDUSD; USDCHF; USDCAD; USDJPY; CADJPY; EURJPY; GBPJPY; AUDJPY; NZDJPY; CHFJPY; EURCHF; GBPCHF; GOLD";
extern string	TimeFrameList = "H1; H4; D1; W1";
//---------------------------------------------------------------------
extern int		ShowAddingFields = 1;							// âûâîä äîïîëíèòåëüíûõ ïîëåé ( ñïðýä è ò.ä. )
//---------------------------------------------------------------------
extern int		InfoTopShift = 20;								// ñìåùåíèå ñâåðõó äëÿ âûâîäèìîé íà ýêðàí èíôîðìàöèè
extern int		InfoLeftShift = 5;								// ñìåùåíèå ñëåâà äëÿ âûâîäèìîé íà ýêðàí èíôîðìàöèè
extern int		FontSize = 10;										// ðàçìåð øðèôòà äëÿ âûâîäà òàáëèöû

//---------------------------------------------------------------------
static string	timeframes[ ];
static int		timeframes_count = 0;
//---------------------------------------------------------------------
static string	currencies[ ];
static int		currencies_count = 0;
//---------------------------------------------------------------------
static int		currency_x[ ] = { 0,   50,  120, 190, 260, 330, 400, 470, 540, 610, 680, 750, 820, 890, 960, 1030, 1110 };
static int		rect_x[ ]     = { 267, 249, 231, 214, 197, 179, 162, 145, 127, 110,  92,  75,  57,  40,  22,    2 };
//---------------------------------------------------------------------
static int		rect_w[ ] = { 1, 1, 2, 2, 4 };		// òîëùèíà ëèíèé ïðÿìîóãîëüíèêîâ
static int		rect_s[ ] = { 4, 6, 8, 12, 14 };	// øèðèíà ïðÿìîóãîëüíèêîâ
static color	rect_c_up[ ] = { PaleGreen, Lime, Lime, Green, Lime };
static color	rect_c_dn[ ] = { Pink, Red, Red, Brown, Red };
static bool		rect_back[ ] = { TRUE, FALSE, FALSE, FALSE, FALSE };
static string	columns[ ] = { "Bid:", "Sprd:", "StLev:", "Hi-Lo:", "AvrgD:" };
//---------------------------------------------------------------------

//---------------------------------------------------------------------
int		tf_start_row;
int		bid_row_count;
//---------------------------------------------------------------------
int		is_initialised = 0;
int		indicator_wnd;
//---------------------------------------------------------------------
double		current_point_multiplier;							// ìíîæèòåëü ïðè âûâîäå íà ýêðàí ïóíêòîâ
double		current_digits;
double		current_point;
//---------------------------------------------------------------------
//	Èíèöèàëèçàöèÿ:
//---------------------------------------------------------------------
int
init( )
{
	is_initialised = 0;
	return( 0 );
}

//---------------------------------------------------------------------
//	Äåèíèöèàëèçàöèÿ:
//---------------------------------------------------------------------
int
deinit( )
{
	delete_table( );
	delete_rects( );
	is_initialised = 0;

	return( 0 );
}

//---------------------------------------------------------------------
//	Âûçûâàåòñÿ ïðè êàæäîì òèêå ïî äàííîìó èíñòðóìåíòó:
//---------------------------------------------------------------------
#define LEFT_SHIFT		260
//---------------------------------------------------------------------
color		price_color;
double	price;
double	price_ma;
//---------------------------------------------------------------------
int
start( )
{
	if( is_initialised == 0 )
	{
		initialise( );
		is_initialised = 1;
	}

	for( int curr_index = 0; curr_index < currencies_count; curr_index++ )
	{
		price = MarketInfo( currencies[ curr_index ], MODE_BID );
		price_ma = iMA( currencies[ curr_index ], PERIOD_M1, 1, 0, MODE_EMA, PRICE_CLOSE, 1 );

		current_digits = MarketInfo( currencies[ curr_index ], MODE_DIGITS );
		if( current_digits == 5 || current_digits == 3 )
		{
			current_point_multiplier = 0.1;
		}
		else
		{
			current_point_multiplier = 1.0;
		}
		current_point = MarketInfo( currencies[ curr_index ], MODE_POINT );

		if( price < price_ma )
			price_color = Red;
		else if ( price > price_ma )
			price_color = Lime;
		else if( price == price_ma )
			price_color = Orange;

		set_cell_text( 1, curr_index + 1, DoubleToStr( price, current_digits ), price_color );

		if( ShowAddingFields == 1 )
		{
			double	R1 = 0, R5 = 0, R10 = 0, R20 = 0, RAvg = 0, AV_Yest, spread, stoplevel, hilo;
			R1 = ( iHigh( currencies[ curr_index ], PERIOD_D1, 1 ) - iLow( currencies[ curr_index ], PERIOD_D1, 1 )) / current_point;
			for( int i = 1; i <= 5; i++ )
			{
				R5 = R5 + ( iHigh( currencies[ curr_index ], PERIOD_D1, i ) - iLow( currencies[ curr_index ], PERIOD_D1, i )) / current_point;
			}
			for( i = 1; i <= 10; i++ )
			{
				R10 = R10 + ( iHigh( currencies[ curr_index ], PERIOD_D1, i ) - iLow( currencies[ curr_index ], PERIOD_D1, i )) / current_point;
			}
			for( i = 1; i <= 20; i++ )
			{
				R20 = R20 + ( iHigh( currencies[ curr_index ], PERIOD_D1, i ) - iLow( currencies[ curr_index ], PERIOD_D1, i )) / current_point;
			}

			RAvg = ( R1 + R5 / 5.0 + R10 / 10.0 + R20 / 20.0 ) / 4.0 * current_point_multiplier;    
			AV_Yest = ( iHigh( currencies[ curr_index ], PERIOD_D1, 1 ) - iLow( currencies[ curr_index ], PERIOD_D1, 1 )) / current_point * current_point_multiplier;

			spread = current_point_multiplier * MarketInfo( currencies[ curr_index ], MODE_SPREAD );
			stoplevel = current_point_multiplier * MarketInfo( currencies[ curr_index ], MODE_STOPLEVEL );
			hilo = ( iHigh( currencies[ curr_index ], PERIOD_D1, 0 ) - iLow( currencies[ curr_index ], PERIOD_D1, 0 )) * current_point_multiplier / current_point;

			string	adding;
			if( spread >= 10.0 )
			{
				adding = "  ";
			}
			else
			{
				adding = "   ";
			}
			set_cell_text( 2, curr_index + 1, adding + DoubleToStr( spread, 1 ), LemonChiffon );

			if( stoplevel >= 100.0 )
			{
				adding = " ";
			}
			else if( stoplevel >= 10.0 )
			{
				adding = "  ";
			}
			else
			{
				adding = "   ";
			}
			set_cell_text( 3, curr_index + 1, adding + DoubleToStr( stoplevel, 1 ), LemonChiffon );

			if( hilo >= 100.0 )
			{
				adding = "";
			}
			else if( hilo >= 10.0 )
			{
				adding = "  ";
			}
			else
			{
				adding = "   ";
			}
			set_cell_text( 4, curr_index + 1, adding + DoubleToStr( hilo, 1 ), LightSteelBlue );

			if( RAvg >= 100.0 )
			{
				adding = "";
			}
			else if( RAvg >= 10.0 )
			{
				adding = "  ";
			}
			else
			{
				adding = "   ";
			}
			if( RAvg >= AV_Yest )
			{
				set_cell_text( 5, curr_index + 1, adding + DoubleToStr( RAvg, 1 ), Lime );
			}
			else
			{
				set_cell_text( 5, curr_index + 1, adding + DoubleToStr( RAvg, 1 ), Red );
			}
		}

		for( int tf_index = 0; tf_index < timeframes_count; tf_index++ )
		{
			int			tf = get_timeframe_from_string( timeframes[ tf_index ] );
			double	dev = get_deviation( currencies[ curr_index ], tf, 0 );
			if( dev > 0.0005 )
			{
				set_cell_text( tf_index + 1 + bid_row_count, curr_index + 1, "+" + DoubleToStr( dev, 3 ) + " %", get_number_color( 0.0005, dev, PaleGreen, Pink, Silver ));
			}
			else if( dev < -0.0005 )
			{
				set_cell_text( tf_index + 1 + bid_row_count, curr_index + 1, " " + DoubleToStr( dev, 3 ) + " %", get_number_color( 0.0005, dev, PaleGreen, Pink, Silver ));
			}
			else
			{
				set_cell_text( tf_index + 1 + bid_row_count, curr_index + 1, " " + DoubleToStr( 0.0, 3 ) + " %", get_number_color( 0.0005, dev, PaleGreen, Pink, Silver ));
			}
	
			create_rect( 0.0, dev, currencies[ curr_index ], timeframes[ tf_index ], rect_x[ curr_index ], rect_s[ tf_index ], rect_w[ tf_index ], get_number_color( 0.0005, dev, rect_c_up[ tf_index ], rect_c_dn[ tf_index ], Silver ), rect_back[ tf_index ] );
		}
	}

	return( 0 );
}

//---------------------------------------------------------------------
//	Óäàëåíèå ãðàôè÷åñêèõ îáúåêòîâ:
//---------------------------------------------------------------------
void
delete_rects( )
{
	for( int column = 0; column < currencies_count; column++ )
	{
		for( int row = 0; row < timeframes_count; row++ )
		{
			ObjectDelete( currencies[ column ] + "-" + timeframes[ row ] );
		}
	}
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
void
create_rect( double _low, double _high, string _symbol, string _timeframe, int _shift, int _size, int _width, color _color, bool _solid )
{
	string	name = _symbol + "-" + _timeframe;
	if( ObjectFind( name ) != indicator_wnd )
	{
		ObjectCreate( name, OBJ_RECTANGLE, indicator_wnd, Time[ _shift + 10 ], _low, Time[ _shift + 20 ], _high );
	}
	else
	{
		ObjectSet( name, OBJPROP_TIME1, Time[ _shift + 10 + ( 12 - _size ) / 2 ] );
		ObjectSet( name, OBJPROP_PRICE1, _low );
		ObjectSet( name, OBJPROP_TIME2, Time[ _shift + 20 - ( 12 - _size ) / 2 ] );
		ObjectSet( name, OBJPROP_PRICE2, _high );
	}
	ObjectSet( name, OBJPROP_WIDTH, _width );
	ObjectSet( name, OBJPROP_BACK, _solid );
	ObjectSet( name, OBJPROP_COLOR, _color );
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
double
get_deviation( string _symbol, int _timeframe, int _shift )
{
	double	dev = 100.0 * ( iClose( _symbol, _timeframe, _shift ) - iOpen( _symbol, _timeframe, _shift )) / iOpen( _symbol, _timeframe, _shift );
	return( dev );
}

//---------------------------------------------------------------------
//	Ïðåîáðàçóåò ÒÔ èç ñòðîêè â ÷èñëî:
//---------------------------------------------------------------------
int
get_timeframe_from_string( string _str )
{
	if( _str == "M1" )
	{
		return( PERIOD_M1 );
	}

	if( _str == "M5" )
	{
		return( PERIOD_M5 );
	}

	if( _str == "M15" )
	{
		return( PERIOD_M15 );
	}

	if( _str == "M30" )
	{
		return( PERIOD_M30 );
	}

	if( _str == "H1" )
	{
		return( PERIOD_H1 );
	}

	if( _str == "H4" )
	{
		return( PERIOD_H4 );
	}

	if( _str == "D1" )
	{
		return( PERIOD_D1 );
	}

	if( _str == "W1" )
	{
		return( PERIOD_W1 );
	}

	if( _str == "MN1" )
	{
		return( PERIOD_MN1 );
	}

	return( PERIOD_D1 );
}

//---------------------------------------------------------------------
//	Íà÷àëüíàÿ èíèöèàëèçàöèÿ:
//---------------------------------------------------------------------
void
initialise( )
{
	indicator_wnd = WindowFind( WindowExpertName( ));
	if( indicator_wnd == -1 )
	{
		indicator_wnd = WindowsTotal( );
	}

	currencies_count = StringToArrayString( CurrencyList, currencies );
	if( currencies_count > 16 )
	{
		currencies_count = 16;
	}

	timeframes_count = StringToArrayString( TimeFrameList, timeframes );
	if( timeframes_count > 4 )
	{
		timeframes_count = 4;
	}

//	Íàñòðîèì íà÷àëüíûå êîîðäèíàòû ñòðîê:
	if( ShowAddingFields == 0 )
	{
		tf_start_row = 2;
		bid_row_count = 1;
	}
	else
	{
		tf_start_row = 6;
		bid_row_count = 5;
	}

	create_table( 0, "CurrencyTable", timeframes_count + 1 + bid_row_count, currencies_count + 1 );
	clear_table( );

//	Èíèöèàëèçèðóåì ïåðâóþ ñòðîêó ( íàçâàíèÿ èíñòðóìåíòîâ ):
	for( int column = 0; column < currencies_count + 1; column++ )
	{
		set_cell_attributes( 0, column, InfoLeftShift + currency_x[ column ], InfoTopShift, LightCyan, FontSize );
		if( column == 0 )
		{
			set_cell_text( 0, column, "", Black );
		}
		else
		{
			set_cell_text( 0, column, currencies[ column - 1 ], get_currency_color( currencies[ column - 1 ] ));
		}
	}

//	Èíèöèàëèçèðóåì âòîðóþ ñòðîêó äëÿ âûâîäà òåêóùèõ êîòèðîâîê:
	for( column = 0; column < currencies_count; column++ )
	{
		for( int row = 0; row < bid_row_count; row++ )
		{
			set_cell_attributes( row + 1, column + 1, InfoLeftShift + currency_x[ column + 1 ] + 3, InfoTopShift + ( row + 1 ) * FontSize * 2, LightCyan, FontSize );
		}
	}

//	Èíèöèàëèçèðóåì ïåðâóþ êîëîíêó äëÿ âûâîäà íàçâàíèé ÒÔ:
	for( int tf_index = 0; tf_index < timeframes_count; tf_index++ )
	{
		set_cell_attributes( tf_index + 1 + bid_row_count, 0, InfoLeftShift + 3, InfoTopShift + 10 + ( tf_index + 1 + bid_row_count ) * FontSize * 2, LightCyan, FontSize );
		set_cell_text( tf_index + 1 + bid_row_count, 0, "%" + timeframes[ tf_index ] + ":", Silver );
	}

//	Èíèöèàëèçèðóåì ïåðâóþ êîëîíêó äëÿ âûâîäà äîïîëíèòåëüíûõ ïîëåé:
	for( int add_index = 0; add_index < bid_row_count; add_index++ )
	{
		set_cell_attributes( add_index + 1, 0, InfoLeftShift + 3, InfoTopShift + ( add_index + 1 ) * FontSize * 2, LightCyan, FontSize );
		set_cell_text( add_index + 1, 0, columns[ add_index ], Silver );
	}

//	Èíèöèàëèçèðóåì ÿ÷åéêè äëÿ âûâîäà èíôîðìàöèè ïî èíñòðóìåíòàì:
	for( tf_index = 0; tf_index < timeframes_count; tf_index++ )
	{
		for( int curr_index = 0; curr_index < currencies_count; curr_index++ )
		{
			set_cell_attributes( tf_index + 1 + bid_row_count, curr_index + 1, InfoLeftShift + currency_x[ curr_index + 1 ], InfoTopShift + 10 + ( tf_index + 1 + bid_row_count ) * FontSize * 2, LightCyan, FontSize );
		}
	}
}

//---------------------------------------------------------------------
//	Ïîëó÷åíèå öâåòà â çàâèñèìîñòè îò íàçâàíèÿ èíñòðóìåíòà:
//---------------------------------------------------------------------
color
get_currency_color( string _currency )
{
	int		i;
	for( i = 0; i < currencies_count; i++ )
	{
		if( StringFind( currencies[ i ], _currency ) != -1 )
		{
			if( StringFind( _currency, "GOLD" ) != -1 )
				return( Gold );
			else if( StringFind( _currency, "JPY" ) != -1 )
				return( NavajoWhite );
			else if( StringFind( _currency, "EUR" ) != -1 )
				return( DeepSkyBlue );
			else if( StringFind( _currency, "GBP" ) != -1 )
				return( DeepSkyBlue );
			else if( StringFind( _currency, "QM" ) != -1 )
				return( Brown );
			else if( StringFind( _currency, "ES" ) != -1 )
				return( LightSalmon );
			else if( StringFind( _currency, "NQ" ) != -1 )
				return( LightSalmon );
			else if( StringFind( _currency, "CHF" ) != -1 )
				return( SpringGreen );
			else if( StringFind( _currency, "CAD" ) != -1 )
				return( SpringGreen );
			else if( StringFind( _currency, "AUD" ) != -1 )
				return( GreenYellow );
			else if( StringFind( _currency, "NZD" ) != -1 )
				return( GreenYellow );

			return( Silver );
		}
	}
	return( Silver );
}

//---------------------------------------------------------------------
//	Ïðîâåðêà íàïðàâëåíèÿ òðåíäà ïî MACD:
//---------------------------------------------------------------------
//	Âîçâðàùàåò:
//		TREND_UP - òðåíä âåðõ;
//		NO_TREND - òðåíä íåîïðåäåëåí;
//		TREND_DN - òðåíä âíèç;
//---------------------------------------------------------------------
int
get_trend_direction_MACD( string _symbol, int _timeframe, int _fast_ma_period, int _slow_ma_period )
{
	HideTestIndicators( true );
	double	macd_value = iMACD( _symbol, _timeframe, _fast_ma_period, _slow_ma_period, 1, PRICE_CLOSE, MODE_MAIN, 0 );
	HideTestIndicators( false );

	if( NormalizeDouble( macd_value, 4 ) > 0.0001 )
		return( TREND_UP );

	if( NormalizeDouble( macd_value, 4 ) < -0.0001 )
		return( TREND_DN );

	return( NO_TREND );
}

//---------------------------------------------------------------------
//	Ïðîâåðêà íàïðàâëåíèÿ òðåíäà ïî RSI:
//---------------------------------------------------------------------
//	Âîçâðàùàåò:
//		TREND_UP - òðåíä âåðõ;
//		NO_TREND - òðåíä íåîïðåäåëåí;
//		TREND_DN - òðåíä âíèç;
//---------------------------------------------------------------------
int
get_trend_direction_RSI( string _symbol, int _timeframe, int _period )
{
	HideTestIndicators( true );
	double	macd_value = iRSI( _symbol, _timeframe, _period, PRICE_CLOSE, 0 );
	HideTestIndicators( false );

	if( NormalizeDouble( macd_value, 4 ) > 50.0 )
		return( TREND_UP );

	if( NormalizeDouble( macd_value, 4 ) < 50.0 )
		return( TREND_DN );

	return( NO_TREND );
}

//---------------------------------------------------------------------
//	Ïðîâåðêà íàïðàâëåíèÿ òðåíäà ïî EMA8 è SMA89 (ðûíî÷íûé ðèòì):
//---------------------------------------------------------------------
//	Âîçâðàùàåò:
//		TREND_UP - òðåíä âåðõ;
//		NO_TREND - òðåíä íåîïðåäåëåí;
//		TREND_DN - òðåíä âíèç;
//---------------------------------------------------------------------
int
get_trend_direction_MarketRithm( string _symbol, int _timeframe, int _fast_ma_period, int _slow_ma_period )
{
	int		market_rithm = 0;

	HideTestIndicators( true );
	double	price_value = NormalizeDouble( iClose( _symbol, _timeframe, 1 ), Digits );
	double	fast_ma_value = NormalizeDouble( iMA( _symbol, _timeframe, _fast_ma_period, 0, MODE_EMA, PRICE_CLOSE, 1 ), Digits );
	double	slow_ma_value = NormalizeDouble( iMA( _symbol, _timeframe, _slow_ma_period, 0, MODE_SMA, PRICE_CLOSE, 1 ), Digits );
	HideTestIndicators( false );

	if( price_value > slow_ma_value )
	{
		market_rithm++;
	}
	
	if( fast_ma_value > fast_ma_value )
	{
		market_rithm++;
	}
	
	if( price_value < slow_ma_value )
	{
		market_rithm--;
	}
	
	if( fast_ma_value < fast_ma_value )
	{
		market_rithm--;
	}
	
	if( market_rithm >= 1 )
		return( TREND_UP );

	if( market_rithm <= -1 )
		return( TREND_DN );

	return( NO_TREND );
}

//---------------------------------------------------------------------
//	Ïðîâåðêà íàïðàâëåíèÿ òðåíäà:
//---------------------------------------------------------------------
//	Âîçâðàùàåò:
//		TREND_UP - òðåíä âåðõ;
//		NO_TREND - òðåíä íåîïðåäåëåí;
//		TREND_DN - òðåíä âíèç;
//---------------------------------------------------------------------
int
TrendDetector( int _mode, string _symbol, int _timeframe, int _fast_ma_period, int _slow_ma_period )
{
	int		trend_direction = NO_TREND;

	switch( _mode )
	{
		case		0:																	//  0 - ïî MACD
			trend_direction = get_trend_direction_MACD( _symbol, _timeframe, _fast_ma_period, _slow_ma_period );
			break;

		case		1:																	//  1 - ïî ìóâèíãó è òåêóùåìó áàðó ( ïî çàêðûòèþ )
			break;

		case		2:																	//  2 - ïî äâóì ìóâèíãàì
			trend_direction = get_trend_direction_MarketRithm( _symbol, _timeframe, _fast_ma_period, _slow_ma_period );
			break;

		case		3:																	//  3 - ïî WPR
			break;

		case		4:																	//  4 - ïî RSI(14)
			trend_direction = get_trend_direction_RSI( _symbol, _timeframe, 14 );
			break;

		default:
			break;
	}

	return( trend_direction );
}

//+----------------------------------------------------------------------------+
//|  Àâòîð    : Êèì Èãîðü Â. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Âåðñèÿ   : 10.10.2008                                                     |
//|  Îïèñàíèå : Ïåðåíîñ âåùåñòâåííûõ ÷èñåë èç ñòðîêè â ìàññèâ                  |
//+----------------------------------------------------------------------------+
//|  Ïàðàìåòðû:                                                                |
//|    st - ñòðîêà âåùåñòâåííûõ ÷èñåë ÷åðåç òî÷êó ñ çàïÿòîé                    |
//|    ad - ìàññèâ âåùåñòâåííûõ ÷èñåë                                          |
//+----------------------------------------------------------------------------+
//|  Âîçâðàò:                                                                  |
//|    Êîëè÷åñòâî ýëåìåíòîâ â ìàññèâå                                          |
//+----------------------------------------------------------------------------+
int
StringToArrayString( string st, string &ad[ ], string _delimiter = ";" )
{
  int    i=0, np;
  string stp;

  ArrayResize(ad, 0);
  while (StringLen(st)>0)
  {
    np = StringFind( st, _delimiter );
    if (np<0) {
      stp=st;
      st="";
    } else {
      stp=StringSubstr(st, 0, np);
      st=StringSubstr(st, np+1);
    }
    i++;
    ArrayResize( ad, i );
    ad[ i - 1 ] = StringTrimLeft( stp );
  }

	return( ArraySize( ad ));
}

//---------------------------------------------------------------------
//	Ïîëó÷åíèå öâåòà â çàâèñèìîñòè îò çíàêà ÷èñëà:
//---------------------------------------------------------------------
color
get_number_color( double _precision, double _number, color _plus, color _minus, color _null )
{
	if( _number > _precision )
	{
		return( _plus );
	}

	if( _number < ( -_precision ))
	{
		return( _minus );
	}

	return( _null );
}





Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains open time of each bar
Series array that contains open prices of each bar
Series array that contains close prices for each bar


Indicator Curves created:


Indicators Used:

Moving average indicator
MACD Histogram
Relative strength index


Custom Indicators Used:

Order Management characteristics:

Other Features: