Page 1 of 1

I need help with _TRO_MA_MULTI

Posted: Thu May 29, 2008 2:38 pm
by Pucio
Hi,

Can you help me to add to the code one MA more. I have problem to do it by myself. I need help, please.

Pucio

the code :

//+------------------------------------------------------------------+
//| _TRO_MA_MULTI |
//| |
//| Copyright ? 2007, Avery T. Horton, Jr. aka TheRumpledOne |
//| |
//| PO BOX 43575, TUCSON, AZ 85733 |
//| |
//| GIFT AND DONATIONS ACCEPTED |
//| |
//| therumpldone@gmail.com |
//+------------------------------------------------------------------+
// I used code from FERRUXX and Robert Hill - Thanks for sharing!
//+------------------------------------------------------------------+

#property copyright "Avery T. Horton, Jr. aka TheRumpledOne"

#property link ""

#property indicator_chart_window

//---- input parameters

//extern string myPair = "" ;
extern int myxstart=130 ;
extern int myystart=11 ;


// indicators parameters
extern string Shift_Settings_test_only = "=== Format: 2007.05.07 00:00 ===";
extern datetime look_time_shift = D'2007.05.07 00:00'; // Shift for test if "test" is true
extern double shift_indicators = 0; // Shift for indicators if "test" is false
extern bool test = false;

string MA_Settings = "=== Moving Average Settings ===";
extern int FastMAPeriod = 9; // Fast Moving Average period
extern int MediumMAPeriod = 24; // Medium Moving Average period
extern int SlowMAPeriod = 38; // Slow Moving Average period
extern int MAMethod = MODE_EMA; // Moving Average method
extern int MAPrice = PRICE_CLOSE; // Moving Average price


double UP_1, UP_2, UP_3, UP_4, UP_5, UP_6, UP_7, UP_8, UP_9, UP_10;
double UP_11, UP_12, UP_13, UP_14, UP_15, UP_16, UP_17, UP_18, UP_19, UP_20;
double UP_21, UP_22, UP_23, UP_24, UP_25, UP_26, UP_27, UP_28, UP_29, UP_30;
double UP_31, UP_32, UP_33, UP_34, UP_35, UP_36, UP_37, UP_38, UP_39, UP_40;
double UP_41, UP_42, UP_43, UP_44, UP_45, UP_46, UP_47, UP_48, UP_49, UP_50;
double UP_51, UP_52, UP_53, UP_54, UP_55, UP_56, UP_57, UP_58, UP_59, UP_60;
double UP_61, UP_62, UP_63, UP_64;

double DOWN_1, DOWN_2, DOWN_3, DOWN_4, DOWN_5, DOWN_6, DOWN_7, DOWN_8, DOWN_9, DOWN_10;
double DOWN_11, DOWN_12, DOWN_13, DOWN_14, DOWN_15, DOWN_16, DOWN_17, DOWN_18, DOWN_19, DOWN_20;
double DOWN_21, DOWN_22, DOWN_23, DOWN_24, DOWN_25, DOWN_26, DOWN_27, DOWN_28, DOWN_29, DOWN_30;
double DOWN_31, DOWN_32, DOWN_33, DOWN_34, DOWN_35, DOWN_36, DOWN_37, DOWN_38, DOWN_39, DOWN_40;
double DOWN_41, DOWN_42, DOWN_43, DOWN_44, DOWN_45, DOWN_46, DOWN_47, DOWN_48, DOWN_49, DOWN_50;
double DOWN_51, DOWN_52, DOWN_53, DOWN_54, DOWN_55, DOWN_56, DOWN_57, DOWN_58, DOWN_59, DOWN_60;
double DOWN_61, DOWN_62, DOWN_63, DOWN_64;

double v0 = 0.764 ;
double v1 = 0.618 ;
double v2 = 0.5 ;
double v3 = 0.382 ;
double v4 = 0.236 ;
double v5 = 0.0 ;

int myPeriod1 = 1 ;
int myPeriod2 = 5 ;
int myPeriod3 = 15 ;
int myPeriod4 = 30 ;
int myPeriod5 = 60 ;
int myPeriod6 = 240 ;
int myPeriod7 = 1440 ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

initGraph();

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
deleteObject();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
string Period2Text(int TmPeriod)
{
switch (TmPeriod)
{
case PERIOD_M1 : return("M1");
case PERIOD_M5 : return("M5");
case PERIOD_M15 : return("M15");
case PERIOD_M30 : return("M30");
case PERIOD_H1 : return("H1");
case PERIOD_H4 : return("H4");
case PERIOD_D1 : return("D1");
case PERIOD_W1 : return("W1");
case PERIOD_MN1 : return("MN1");
}
return ("ERR");
}

//+---------------

double prOpen( int i, int j)
{
return (iOpen(NULL,i,j));
}
//+---------------
double prHigh( int i, int j)
{
return (iHigh(NULL,i,j));
}
//+---------------


double prLow( int i, int j)
{
return (iLow(NULL,i,j));
}
//+---------------
double prClose( int i, int j)
{
return (iClose(NULL,i,j));
}
//+---------------


int start()
{
double xhigh1 = prHigh( myPeriod1, 1 );
double xlow1 = prLow( myPeriod1, 1 );
double xclose1 = prClose( myPeriod1, 0 );
double xopen1 = prOpen( myPeriod1, 0 );
double xmid1 = ( xhigh1 + xlow1 ) * 0.5 ;
double xrange1 = xhigh1 - xlow1 ;

double xhigh2 = prHigh( myPeriod2, 1 );
double xlow2 = prLow( myPeriod2, 1 );
double xclose2 = prClose( myPeriod2, 0 );
double xopen2 = prOpen( myPeriod2, 0 );
double xmid2 = ( xhigh2 + xlow2 ) * 0.5 ;
double xrange2 = xhigh2 - xlow2 ;

double xhigh3 = prHigh( myPeriod3, 1 );
double xlow3 = prLow( myPeriod3, 1 );
double xclose3 = prClose( myPeriod3, 0 );
double xopen3 = prOpen( myPeriod3, 0 );
double xmid3 = ( xhigh3 + xlow3 ) * 0.5 ;
double xrange3 = xhigh3 - xlow3 ;

double xhigh4 = prHigh( myPeriod4, 1 );
double xlow4 = prLow( myPeriod4, 1 );
double xclose4 = prClose( myPeriod4, 0 );
double xopen4 = prOpen( myPeriod4, 0 );
double xmid4 = ( xhigh4 + xlow4 ) * 0.5 ;
double xrange4 = xhigh4 - xlow4 ;

double xhigh5 = prHigh( myPeriod5, 1 );
double xlow5 = prLow( myPeriod5, 1 );
double xclose5 = prClose( myPeriod5, 0 );
double xopen5 = prOpen( myPeriod5, 0 );
double xmid5 = ( xhigh5 + xlow5 ) * 0.5 ;
double xrange5 = xhigh5 - xlow5 ;

double xhigh6 = prHigh( myPeriod6, 1 );
double xlow6 = prLow( myPeriod6, 1 );
double xclose6 = prClose( myPeriod6, 0 );
double xopen6 = prOpen( myPeriod6, 0 );
double xmid6 = ( xhigh6 + xlow6 ) * 0.5 ;
double xrange6 = xhigh6 - xlow6 ;

double xhigh7 = prHigh( myPeriod7, 1 );
double xlow7 = prLow( myPeriod7, 1 );
double xclose7 = prClose( myPeriod7, 0 );
double xopen7 = prOpen( myPeriod7, 0 );
double xmid7 = ( xhigh7 + xlow7 ) * 0.5 ;
double xrange7 = xhigh7 - xlow7 ;

// Shift calculation for indicators (tests only)

double shift_1, shift_5, shift_15, shift_30, shift_60, shift_240, shift_1440, shift_10080;

if( test == true )
{
shift_1=iBarShift(NULL,PERIOD_M1,look_time_shift,false);
shift_5=iBarShift(NULL,PERIOD_M5,look_time_shift,false);
shift_15=iBarShift(NULL,PERIOD_M15,look_time_shift,false);
shift_30=iBarShift(NULL,PERIOD_M30,look_time_shift,false);
shift_60=iBarShift(NULL,PERIOD_H1,look_time_shift,false);
shift_240=iBarShift(NULL,PERIOD_H4,look_time_shift,false);
shift_1440=iBarShift(NULL,PERIOD_D1,look_time_shift,false);
shift_10080=iBarShift(NULL,PERIOD_W1,look_time_shift,false);
}
else
{
shift_1=shift_indicators;
shift_5=shift_indicators;
shift_15=shift_indicators;
shift_30=shift_indicators;
shift_60=shift_indicators;
shift_240=shift_indicators;
shift_1440=shift_indicators;
shift_10080=shift_indicators;
}

// Indicator (Moving Average)

color color_ind = PowderBlue;

string MAfast_Trend_1, MAfast_Trend_5, MAfast_Trend_15, MAfast_Trend_30, MAfast_Trend_60, MAfast_Trend_240, MAfast_Trend_1440, MAfast_Trend_10080;
string MAmedium_Trend_1, MAmedium_Trend_5, MAmedium_Trend_15, MAmedium_Trend_30, MAmedium_Trend_60, MAmedium_Trend_240, MAmedium_Trend_1440, MAmedium_Trend_10080;
string MAslow_Trend_1, MAslow_Trend_5, MAslow_Trend_15, MAslow_Trend_30, MAslow_Trend_60, MAslow_Trend_240, MAslow_Trend_1440, MAslow_Trend_10080;
double x;
color color_indic;

// FAST

double l;
if(FastMAPeriod < 10) { l=210; }
if(FastMAPeriod >= 10) { l=206; }
if(FastMAPeriod >= 100) { l=202; }


double FastMA_1_1 = iMA(NULL,PERIOD_M1,FastMAPeriod,0,MAMethod,MAPrice,shift_1);
double FastMA_2_1 = iMA(NULL,PERIOD_M1,FastMAPeriod,0,MAMethod,MAPrice,shift_1+1);

if ((FastMA_1_1 > FastMA_2_1)) { MAfast_Trend_1 = "UP"; x = 216; color_indic = Lime; UP_1 = 1; DOWN_1 = 0; }
if ((FastMA_1_1 < FastMA_2_1)) { MAfast_Trend_1 = "DOWN"; x = 206; color_indic = Red; UP_1 = 0; DOWN_1 = 1; }


double FastMA_1_5 = iMA(NULL,PERIOD_M5,FastMAPeriod,0,MAMethod,MAPrice,shift_5);
double FastMA_2_5 = iMA(NULL,PERIOD_M5,FastMAPeriod,0,MAMethod,MAPrice,shift_5+1);

if ((FastMA_1_5 > FastMA_2_5)) { MAfast_Trend_5 = "UP"; x = 216; color_indic = Lime; UP_2 = 1; DOWN_2 = 0; }
if ((FastMA_1_5 < FastMA_2_5)) { MAfast_Trend_5 = "DOWN"; x = 206; color_indic = Red; UP_2 = 0; DOWN_2 = 1; }


double FastMA_1_15 = iMA(NULL,PERIOD_M15,FastMAPeriod,0,MAMethod,MAPrice,shift_15);
double FastMA_2_15 = iMA(NULL,PERIOD_M15,FastMAPeriod,0,MAMethod,MAPrice,shift_15+1);

if ((FastMA_1_15 > FastMA_2_15)) { MAfast_Trend_15 = "UP"; x = 216; color_indic = Lime; UP_3 = 1; DOWN_3 = 0; }
if ((FastMA_1_15 < FastMA_2_15)) { MAfast_Trend_15 = "DOWN"; x = 206; color_indic = Red; UP_3 = 0; DOWN_3 = 1; }


double FastMA_1_30 = iMA(NULL,PERIOD_M30,FastMAPeriod,0,MAMethod,MAPrice,shift_30);
double FastMA_2_30 = iMA(NULL,PERIOD_M30,FastMAPeriod,0,MAMethod,MAPrice,shift_30+1);

if ((FastMA_1_30 > FastMA_2_30)) { MAfast_Trend_30 = "UP"; x = 216; color_indic = Lime; UP_4 = 1; DOWN_4 = 0; }
if ((FastMA_1_30 < FastMA_2_30)) { MAfast_Trend_30 = "DOWN"; x = 206; color_indic = Red; UP_4 = 0; DOWN_4 = 1; }


double FastMA_1_60 = iMA(NULL,PERIOD_H1,FastMAPeriod,0,MAMethod,MAPrice,shift_60);
double FastMA_2_60 = iMA(NULL,PERIOD_H1,FastMAPeriod,0,MAMethod,MAPrice,shift_60+1);

if ((FastMA_1_60 > FastMA_2_60)) { MAfast_Trend_60 = "UP"; x = 216; color_indic = Lime; UP_5 = 1; DOWN_5 = 0; }
if ((FastMA_1_60 < FastMA_2_60)) { MAfast_Trend_60 = "DOWN"; x = 206; color_indic = Red; UP_5 = 0; DOWN_5 = 1; }


double FastMA_1_240 = iMA(NULL,PERIOD_H4,FastMAPeriod,0,MAMethod,MAPrice,shift_240);
double FastMA_2_240 = iMA(NULL,PERIOD_H4,FastMAPeriod,0,MAMethod,MAPrice,shift_240+1);

if ((FastMA_1_240 > FastMA_2_240)) { MAfast_Trend_240 = "UP"; x = 216; color_indic = Lime; UP_6 = 1; DOWN_6 = 0; }
if ((FastMA_1_240 < FastMA_2_240)) { MAfast_Trend_240 = "DOWN"; x = 206; color_indic = Red; UP_6 = 0; DOWN_6 = 1; }


double FastMA_1_1440 = iMA(NULL,PERIOD_D1,FastMAPeriod,0,MAMethod,MAPrice,shift_1440);
double FastMA_2_1440 = iMA(NULL,PERIOD_D1,FastMAPeriod,0,MAMethod,MAPrice,shift_1440+1);

if ((FastMA_1_1440 > FastMA_2_1440)) { MAfast_Trend_1440 = "UP"; x = 216; color_indic = Lime; UP_7 = 1; DOWN_7 = 0; }
if ((FastMA_1_1440 < FastMA_2_1440)) { MAfast_Trend_1440 = "DOWN"; x = 206; color_indic = Red; UP_7 = 0; DOWN_7 = 1; }


double FastMA_1_10080 = iMA(NULL,PERIOD_W1,FastMAPeriod,0,MAMethod,MAPrice,shift_10080);
double FastMA_2_10080 = iMA(NULL,PERIOD_W1,FastMAPeriod,0,MAMethod,MAPrice,shift_10080+1);

if ((FastMA_1_10080 > FastMA_2_10080)) { MAfast_Trend_10080 = "UP"; x = 216; color_indic = Lime; UP_8 = 1; DOWN_8 = 0; }
if ((FastMA_1_10080 < FastMA_2_10080)) { MAfast_Trend_10080 = "DOWN"; x = 206; color_indic = Red; UP_8 = 0; DOWN_8 = 1; }


// MEDIUM

double m;
if(MediumMAPeriod < 10) { m=260; }
if(MediumMAPeriod >= 10) { m=256; }
if(MediumMAPeriod >= 100) { m=252; }


double MediumMA_1_1 = iMA(NULL,PERIOD_M1,MediumMAPeriod,0,MAMethod,MAPrice,shift_1);
double MediumMA_2_1 = iMA(NULL,PERIOD_M1,MediumMAPeriod,0,MAMethod,MAPrice,shift_1+1);

if ((MediumMA_1_1 > MediumMA_2_1)) { MAmedium_Trend_1 = "UP"; x = 266; color_indic = Lime; UP_9 = 1; DOWN_9 = 0; }
if ((MediumMA_1_1 < MediumMA_2_1)) { MAmedium_Trend_1 = "DOWN"; x = 256; color_indic = Red; UP_9 = 0; DOWN_9 = 1; }


double MediumMA_1_5 = iMA(NULL,PERIOD_M5,MediumMAPeriod,0,MAMethod,MAPrice,shift_5);
double MediumMA_2_5 = iMA(NULL,PERIOD_M5,MediumMAPeriod,0,MAMethod,MAPrice,shift_5+1);

if ((MediumMA_1_5 > MediumMA_2_5)) { MAmedium_Trend_5 = "UP"; x = 266; color_indic = Lime; UP_10 = 1; DOWN_10 = 0; }
if ((MediumMA_1_5 < MediumMA_2_5)) { MAmedium_Trend_5 = "DOWN"; x = 256; color_indic = Red; UP_10 = 0; DOWN_10 = 1; }


double MediumMA_1_15 = iMA(NULL,PERIOD_M15,MediumMAPeriod,0,MAMethod,MAPrice,shift_15);
double MediumMA_2_15 = iMA(NULL,PERIOD_M15,MediumMAPeriod,0,MAMethod,MAPrice,shift_15+1);

if ((MediumMA_1_15 > MediumMA_2_15)) { MAmedium_Trend_15 = "UP"; x = 266; color_indic = Lime; UP_11 = 1; DOWN_11 = 0; }
if ((MediumMA_1_15 < MediumMA_2_15)) { MAmedium_Trend_15 = "DOWN"; x = 256; color_indic = Red; UP_11 = 0; DOWN_11 = 1; }


double MediumMA_1_30 = iMA(NULL,PERIOD_M30,MediumMAPeriod,0,MAMethod,MAPrice,shift_30);
double MediumMA_2_30 = iMA(NULL,PERIOD_M30,MediumMAPeriod,0,MAMethod,MAPrice,shift_30+1);

if ((MediumMA_1_30 > MediumMA_2_30)) { MAmedium_Trend_30 = "UP"; x = 266; color_indic = Lime; UP_12 = 1; DOWN_12 = 0; }
if ((MediumMA_1_30 < MediumMA_2_30)) { MAmedium_Trend_30 = "DOWN"; x = 256; color_indic = Red; UP_12 = 0; DOWN_12 = 1; }


double MediumMA_1_60 = iMA(NULL,PERIOD_H1,MediumMAPeriod,0,MAMethod,MAPrice,shift_60);
double MediumMA_2_60 = iMA(NULL,PERIOD_H1,MediumMAPeriod,0,MAMethod,MAPrice,shift_60+1);

if ((MediumMA_1_60 > MediumMA_2_60)) { MAmedium_Trend_60 = "UP"; x = 266; color_indic = Lime; UP_13 = 1; DOWN_13 = 0; }
if ((MediumMA_1_60 < MediumMA_2_60)) { MAmedium_Trend_60 = "DOWN"; x = 256; color_indic = Red; UP_13 = 0; DOWN_13 = 1; }


double MediumMA_1_240 = iMA(NULL,PERIOD_H4,MediumMAPeriod,0,MAMethod,MAPrice,shift_240);
double MediumMA_2_240 = iMA(NULL,PERIOD_H4,MediumMAPeriod,0,MAMethod,MAPrice,shift_240+1);

if ((MediumMA_1_240 > MediumMA_2_240)) { MAmedium_Trend_240 = "UP"; x = 266; color_indic = Lime; UP_14 = 1; DOWN_14 = 0; }
if ((MediumMA_1_240 < MediumMA_2_240)) { MAmedium_Trend_240 = "DOWN"; x = 256; color_indic = Red; UP_14 = 0; DOWN_14 = 1; }

double MediumMA_1_1440 = iMA(NULL,PERIOD_D1,MediumMAPeriod,0,MAMethod,MAPrice,shift_1440);
double MediumMA_2_1440 = iMA(NULL,PERIOD_D1,MediumMAPeriod,0,MAMethod,MAPrice,shift_1440+1);

if ((MediumMA_1_1440 > MediumMA_2_1440)) { MAmedium_Trend_1440 = "UP"; x = 266; color_indic = Lime; UP_15 = 1; DOWN_15 = 0; }
if ((MediumMA_1_1440 < MediumMA_2_1440)) { MAmedium_Trend_1440 = "DOWN"; x = 256; color_indic = Red; UP_15 = 0; DOWN_15 = 1; }


double MediumMA_1_10080 = iMA(NULL,PERIOD_W1,MediumMAPeriod,0,MAMethod,MAPrice,shift_10080);
double MediumMA_2_10080 = iMA(NULL,PERIOD_W1,MediumMAPeriod,0,MAMethod,MAPrice,shift_10080+1);

if ((MediumMA_1_10080 > MediumMA_2_10080)) { MAmedium_Trend_10080 = "UP"; x = 266; color_indic = Lime; UP_16 = 1; DOWN_16 = 0; }
if ((MediumMA_1_10080 < MediumMA_2_10080)) { MAmedium_Trend_10080 = "DOWN"; x = 256; color_indic = Red; UP_16 = 0; DOWN_16 = 1; }


// SLOW

double n;
if(SlowMAPeriod < 10) { n=310; }
if(SlowMAPeriod >= 10) { n=306; }
if(SlowMAPeriod >= 100) { n=302; }



double SlowMA_1_1 = iMA(NULL,PERIOD_M1,SlowMAPeriod,0,MAMethod,MAPrice,shift_1);
double SlowMA_2_1 = iMA(NULL,PERIOD_M1,SlowMAPeriod,0,MAMethod,MAPrice,shift_1+1);

if ((SlowMA_1_1 > SlowMA_2_1)) { MAslow_Trend_1 = "UP"; x = 316; color_indic = Lime; UP_17 = 1; DOWN_17 = 0; }
if ((SlowMA_1_1 < SlowMA_2_1)) { MAslow_Trend_1 = "DOWN"; x = 306; color_indic = Red; UP_17 = 0; DOWN_17 = 1; }


double SlowMA_1_5 = iMA(NULL,PERIOD_M5,SlowMAPeriod,0,MAMethod,MAPrice,shift_5);
double SlowMA_2_5 = iMA(NULL,PERIOD_M5,SlowMAPeriod,0,MAMethod,MAPrice,shift_5+1);

if ((SlowMA_1_5 > SlowMA_2_5)) { MAslow_Trend_5 = "UP"; x = 316; color_indic = Lime; UP_18 = 1; DOWN_18 = 0; }
if ((SlowMA_1_5 < SlowMA_2_5)) { MAslow_Trend_5 = "DOWN"; x = 306; color_indic = Red; UP_18 = 0; DOWN_18 = 1; }


double SlowMA_1_15 = iMA(NULL,PERIOD_M15,SlowMAPeriod,0,MAMethod,MAPrice,shift_15);
double SlowMA_2_15 = iMA(NULL,PERIOD_M15,SlowMAPeriod,0,MAMethod,MAPrice,shift_15+1);

if ((SlowMA_1_15 > SlowMA_2_15)) { MAslow_Trend_15 = "UP"; x = 316; color_indic = Lime; UP_19 = 1; DOWN_19 = 0; }
if ((SlowMA_1_15 < SlowMA_2_15)) { MAslow_Trend_15 = "DOWN"; x = 306; color_indic = Red; UP_19 = 0; DOWN_19 = 1; }


double SlowMA_1_30 = iMA(NULL,PERIOD_M30,SlowMAPeriod,0,MAMethod,MAPrice,shift_30);
double SlowMA_2_30 = iMA(NULL,PERIOD_M30,SlowMAPeriod,0,MAMethod,MAPrice,shift_30+1);

if ((SlowMA_1_30 > SlowMA_2_30)) { MAslow_Trend_30 = "UP"; x = 316; color_indic = Lime; UP_20 = 1; DOWN_20 = 0; }
if ((SlowMA_1_30 < SlowMA_2_30)) { MAslow_Trend_30 = "DOWN"; x = 306; color_indic = Red; UP_20 = 0; DOWN_20 = 1; }

double SlowMA_1_60 = iMA(NULL,PERIOD_H1,SlowMAPeriod,0,MAMethod,MAPrice,shift_60);
double SlowMA_2_60 = iMA(NULL,PERIOD_H1,SlowMAPeriod,0,MAMethod,MAPrice,shift_60+1);

if ((SlowMA_1_60 > SlowMA_2_60)) { MAslow_Trend_60 = "UP"; x = 316; color_indic = Lime; UP_21 = 1; DOWN_21 = 0; }
if ((SlowMA_1_60 < SlowMA_2_60)) { MAslow_Trend_60 = "DOWN"; x = 306; color_indic = Red; UP_21 = 0; DOWN_21 = 1; }

double SlowMA_1_240 = iMA(NULL,PERIOD_H4,SlowMAPeriod,0,MAMethod,MAPrice,shift_240);
double SlowMA_2_240 = iMA(NULL,PERIOD_H4,SlowMAPeriod,0,MAMethod,MAPrice,shift_240+1);

if ((SlowMA_1_240 > SlowMA_2_240)) { MAslow_Trend_240 = "UP"; x = 316; color_indic = Lime; UP_22 = 1; DOWN_22 = 0; }
if ((SlowMA_1_240 < SlowMA_2_240)) { MAslow_Trend_240 = "DOWN"; x = 306; color_indic = Red; UP_22 = 0; DOWN_22 = 1; }

double SlowMA_1_1440 = iMA(NULL,PERIOD_D1,SlowMAPeriod,0,MAMethod,MAPrice,shift_1440);
double SlowMA_2_1440 = iMA(NULL,PERIOD_D1,SlowMAPeriod,0,MAMethod,MAPrice,shift_1440+1);

if ((SlowMA_1_1440 > SlowMA_2_1440)) { MAslow_Trend_1440 = "UP"; x = 316; color_indic = Lime; UP_23 = 1; DOWN_23 = 0; }
if ((SlowMA_1_1440 < SlowMA_2_1440)) { MAslow_Trend_1440 = "DOWN"; x = 306; color_indic = Red; UP_23 = 0; DOWN_23 = 1; }

double SlowMA_1_10080 = iMA(NULL,PERIOD_W1,SlowMAPeriod,0,MAMethod,MAPrice,shift_10080);
double SlowMA_2_10080 = iMA(NULL,PERIOD_W1,SlowMAPeriod,0,MAMethod,MAPrice,shift_10080+1);

if ((SlowMA_1_10080 > SlowMA_2_10080)) { MAslow_Trend_10080 = "UP"; x = 316; color_indic = Lime; UP_24 = 1; DOWN_24 = 0; }
if ((SlowMA_1_10080 < SlowMA_2_10080)) { MAslow_Trend_10080 = "DOWN"; x = 306; color_indic = Red; UP_24 = 0; DOWN_24 = 1; }



objectBlank();
paintCol1(UP_1, UP_9, UP_17);
paintCol2(UP_2, UP_10, UP_18);
paintCol3(UP_3, UP_11, UP_19);
paintCol4(UP_4, UP_12, UP_20);
paintCol5(UP_5, UP_13, UP_21);
paintCol6(UP_6, UP_14, UP_22);
paintCol7(UP_7, UP_15, UP_23);

paintLine();

//----
return(0);
}
//+------------------------------------------------------------------+


void initGraph()
{
deleteObject();


int xstart=myxstart, xinc=20;

int ystart=myystart, yinc=8;
int ystart1=ystart+yinc;
int ystart2=ystart+yinc*2;
int ystart3=ystart+yinc*3;
int ystart4=ystart+yinc*4;
int ystart5=ystart+yinc*5;

objectCreate("MA_1_0",xstart,ystart5);
objectCreate("MA_1_1",xstart,ystart4);
objectCreate("MA_1_2",xstart,ystart3);
objectCreate("MA_1_3",xstart,ystart2);
objectCreate("MA_1_4",xstart,ystart1);
objectCreate("MA_1_5",xstart,ystart);
objectCreate("MA_1",xstart+2,ystart+1,Period2Text(myPeriod1),8,"Arial Narrow",SkyBlue);
objectCreate("MA_1p",xstart+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart2 = xstart - xinc ;

objectCreate("MA_2_0",xstart2,ystart5);
objectCreate("MA_2_1",xstart2,ystart4);
objectCreate("MA_2_2",xstart2,ystart3);
objectCreate("MA_2_3",xstart2,ystart2);
objectCreate("MA_2_4",xstart2,ystart1);
objectCreate("MA_2_5",xstart2,ystart);
objectCreate("MA_2",xstart2+2,ystart+1,Period2Text(myPeriod2),8,"Arial Narrow",SkyBlue);
objectCreate("MA_2p",xstart2+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart3 = xstart2 - xinc ;

objectCreate("MA_3_0",xstart3,ystart5);
objectCreate("MA_3_1",xstart3,ystart4);
objectCreate("MA_3_2",xstart3,ystart3);
objectCreate("MA_3_3",xstart3,ystart2);
objectCreate("MA_3_4",xstart3,ystart1);
objectCreate("MA_3_5",xstart3,ystart);
objectCreate("MA_3",xstart3+2,ystart+1,Period2Text(myPeriod3),8,"Arial Narrow",SkyBlue);
objectCreate("MA_3p",xstart3+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart4 = xstart3 - xinc ;

objectCreate("MA_4_0",xstart4,ystart5);
objectCreate("MA_4_1",xstart4,ystart4);
objectCreate("MA_4_2",xstart4,ystart3);
objectCreate("MA_4_3",xstart4,ystart2);
objectCreate("MA_4_4",xstart4,ystart1);
objectCreate("MA_4_5",xstart4,ystart);
objectCreate("MA_4",xstart4+2,ystart+1,Period2Text(myPeriod4),8,"Arial Narrow",SkyBlue);
objectCreate("MA_4p",xstart4+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart5 = xstart4 - xinc ;

objectCreate("MA_5_0",xstart5,ystart5);
objectCreate("MA_5_1",xstart5,ystart4);
objectCreate("MA_5_2",xstart5,ystart3);
objectCreate("MA_5_3",xstart5,ystart2);
objectCreate("MA_5_4",xstart5,ystart1);
objectCreate("MA_5_5",xstart5,ystart);
objectCreate("MA_5",xstart5+2,ystart+1,Period2Text(myPeriod5),8,"Arial Narrow",SkyBlue);
objectCreate("MA_5p",xstart5+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart6 = xstart5 - xinc ;

objectCreate("MA_6_0",xstart6,ystart5);
objectCreate("MA_6_1",xstart6,ystart4);
objectCreate("MA_6_2",xstart6,ystart3);
objectCreate("MA_6_3",xstart6,ystart2);
objectCreate("MA_6_4",xstart6,ystart1);
objectCreate("MA_6_5",xstart6,ystart);
objectCreate("MA_6",xstart6+2,ystart+1,Period2Text(myPeriod6),8,"Arial Narrow",SkyBlue);
objectCreate("MA_6p",xstart6+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);

int xstart7 = xstart6 - xinc ;

objectCreate("MA_7_0",xstart7,ystart5);
objectCreate("MA_7_1",xstart7,ystart4);
objectCreate("MA_7_2",xstart7,ystart3);
objectCreate("MA_7_3",xstart7,ystart2);
objectCreate("MA_7_4",xstart7,ystart1);
objectCreate("MA_7_5",xstart7,ystart);
objectCreate("MA_7",xstart7+2,ystart+1,Period2Text(myPeriod7),8,"Arial Narrow",SkyBlue);
objectCreate("MA_7p",xstart7+4,ystart+10,DoubleToStr(9,1),8,"Arial Narrow",Silver);


objectCreate("line97",xstart7,ystart+70,"-- Moving Average Trend --",10,"Arial",DimGray);
objectCreate("sign",xstart7,ystart-10,"??? MovAvg MULTI ? ???",8,"Arial Narrow",DimGray);
objectCreate("fma",xstart+24,ystart5-2,FastMAPeriod,8,"Arial Narrow",DimGray);
objectCreate("mma",xstart+24,ystart4-2,MediumMAPeriod ,8,"Arial Narrow",DimGray);
objectCreate("sma",xstart+24,ystart3-2,SlowMAPeriod ,8,"Arial Narrow",DimGray);

}

//+------------------------------------------------------------------+
void objectCreate(string name,int x,int y,string text="-",int size=42,
string font="Arial",color colour=CLR_NONE)
{
ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet(name,OBJPROP_CORNER,3);
ObjectSet(name,OBJPROP_COLOR,colour);
ObjectSet(name,OBJPROP_XDISTANCE,x);
ObjectSet(name,OBJPROP_YDISTANCE,y);
ObjectSetText(name,text,size,font,colour);
}

void deleteObject()
{
ObjectDelete("fma");
ObjectDelete("mma");
ObjectDelete("sma");
ObjectDelete("sign");
ObjectDelete("line97");

ObjectDelete("MA_1_0");
ObjectDelete("MA_1_1");
ObjectDelete("MA_1_2");
ObjectDelete("MA_1_3");
ObjectDelete("MA_1_4");
ObjectDelete("MA_1_5");
ObjectDelete("MA_1");
ObjectDelete("MA_1p");

ObjectDelete("MA_2_0");
ObjectDelete("MA_2_1");
ObjectDelete("MA_2_2");
ObjectDelete("MA_2_3");
ObjectDelete("MA_2_4");
ObjectDelete("MA_2_5");
ObjectDelete("MA_2");
ObjectDelete("MA_2p");

ObjectDelete("MA_3_0");
ObjectDelete("MA_3_1");
ObjectDelete("MA_3_2");
ObjectDelete("MA_3_3");
ObjectDelete("MA_3_4");
ObjectDelete("MA_3_5");
ObjectDelete("MA_3");
ObjectDelete("MA_3p");

ObjectDelete("MA_4_0");
ObjectDelete("MA_4_1");
ObjectDelete("MA_4_2");
ObjectDelete("MA_4_3");
ObjectDelete("MA_4_4");
ObjectDelete("MA_4_5");
ObjectDelete("MA_4");
ObjectDelete("MA_4p");

ObjectDelete("MA_5_0");
ObjectDelete("MA_5_1");
ObjectDelete("MA_5_2");
ObjectDelete("MA_5_3");
ObjectDelete("MA_5_4");
ObjectDelete("MA_5_5");
ObjectDelete("MA_5");
ObjectDelete("MA_5p");

ObjectDelete("MA_6_0");
ObjectDelete("MA_6_1");
ObjectDelete("MA_6_2");
ObjectDelete("MA_6_3");
ObjectDelete("MA_6_4");
ObjectDelete("MA_6_5");
ObjectDelete("MA_6");
ObjectDelete("MA_6p");

ObjectDelete("MA_7_0");
ObjectDelete("MA_7_1");
ObjectDelete("MA_7_2");
ObjectDelete("MA_7_3");
ObjectDelete("MA_7_4");
ObjectDelete("MA_7_5");
ObjectDelete("MA_7");
ObjectDelete("MA_7p");

}

void objectBlank()
{

ObjectSet("MA_1_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_1p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_2_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_2p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_3_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_3p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_4_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_4p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_5_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_5p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_6_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_6p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("MA_7_0",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7_1",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7_2",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7_3",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7_4",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7_5",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7",OBJPROP_COLOR,CLR_NONE);
ObjectSet("MA_7p",OBJPROP_COLOR,CLR_NONE);

ObjectSet("line98",OBJPROP_COLOR,CLR_NONE);
ObjectSet("line97",OBJPROP_COLOR,CLR_NONE);
ObjectSet("fma",OBJPROP_COLOR,CLR_NONE);
ObjectSet("mma",OBJPROP_COLOR,CLR_NONE);
ObjectSet("sma",OBJPROP_COLOR,CLR_NONE);
ObjectSet("line97",OBJPROP_COLOR,CLR_NONE);


}

void paintCol1(double value1, double value2, double value3 )
{


if (value3 == 1) ObjectSet("MA_1_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_1_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_1_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_1_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_1_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_1_3",OBJPROP_COLOR,Red);
ObjectSet("MA_1",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_1p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_1",value);
}

void paintCol2(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_2_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_2_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_2_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_2_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_2_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_2_3",OBJPROP_COLOR,Red);
ObjectSet("MA_2",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_2p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_2",value);
}


void paintCol3(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_3_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_3_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_3_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_3_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_3_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_3_3",OBJPROP_COLOR,Red);
ObjectSet("MA_3",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_3p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_3",value);
}

void paintCol4(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_4_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_4_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_4_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_4_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_4_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_4_3",OBJPROP_COLOR,Red);
ObjectSet("MA_4",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_4p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_4",value);
}

void paintCol5(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_5_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_5_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_5_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_5_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_5_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_5_3",OBJPROP_COLOR,Red);
ObjectSet("MA_5",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_5p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_5",value);
}

void paintCol6(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_6_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_6_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_6_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_6_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_6_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_6_3",OBJPROP_COLOR,Red);
ObjectSet("MA_6",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_6p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_6",value);
}

void paintCol7(double value1, double value2, double value3 )
{
if (value3 == 1) ObjectSet("MA_7_5",OBJPROP_COLOR,Lime);
if (value3 == 0) ObjectSet("MA_7_5",OBJPROP_COLOR,Red);
if (value2 == 1) ObjectSet("MA_7_4",OBJPROP_COLOR,Lime);
if (value2 == 0) ObjectSet("MA_7_4",OBJPROP_COLOR,Red);
if (value1 == 1) ObjectSet("MA_7_3",OBJPROP_COLOR,Lime);
if (value1 == 0) ObjectSet("MA_7_3",OBJPROP_COLOR,Red);
ObjectSet("MA_7",OBJPROP_COLOR,SkyBlue);
// ObjectSetText("MA_7p",DoubleToStr(value*100,0),8,"Arial Narrow",Silver);
// GlobalVariableSet("MA_7",value);
}



void paintLine()
{
ObjectSet("line98",OBJPROP_COLOR,DimGray);
ObjectSet("line97",OBJPROP_COLOR,DimGray);
ObjectSet("fma",OBJPROP_COLOR,DimGray);
ObjectSet("mma",OBJPROP_COLOR,DimGray);
ObjectSet("sma",OBJPROP_COLOR,DimGray);

}