//+------------------------------------------------------------------+
//|                                                 NB10_Dashbar.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyleft 2012"
#property link      ""
#property indicator_chart_window

//---- input parameters



extern   string ____CurrencyNameFilter____ ="eg: JPY";
extern   bool useCurrencyNameFilter = false;
extern   string CurrencyNameFilter = "AUDJPY";


extern   string _________Filters___________ = "true=\"must\",false=\"dont care\"";
extern   bool SameDirection = false;
extern   bool NoP = false;
extern   bool NoS1R1 = false;
extern   bool NoS2R2 = false;
extern   bool NoS3R3 = false;

extern string _________D1_Settings___________;
extern   bool D1_08 = false;
extern   bool D1_04 = false;

extern string _________H4_Settings___________;
extern   bool TouchPivots4 = false;
extern   bool Last2BarsTouching4 = false;
extern   bool H4_08 = false;
extern   bool H4_04 = false;

extern string _________H1_Settings___________;
extern   bool TouchPivots1 = false;
extern   bool Last2BarsTouching1 = false;
extern   bool H1_08 = false;
extern   bool H1_04 = false;

extern string  _________M30_Settings__________;
extern   bool TouchPivots30 = false;
extern   bool Last2BarsTouching30 = false;
extern   bool M30_08=false;
extern   bool M30_04=false;

extern   string _________Sort_Settings_________;
extern   bool SortByPow=true;
extern   bool SortBySlope=false;
extern bool ReSortEveryTick=true;
extern bool UseAbslouteValues=true;
extern   string Tf_Pow_Choice = "1440, 240, 60 or 30";
extern   int Choice = 240;
extern   string _________Appearance___________;
extern   int LabelCorner =0;
extern   int baseX = 30;
extern   int baseY = 15;
extern   int cellHeight = 30;
extern   int cellWidth = 100;
extern   int fontsize = 14;
extern color above_8 = Lime;
extern color above_4 = YellowGreen;
extern color inside_4 = Goldenrod;
extern color below_4 = Red;
extern color below_8 = Pink;
extern color Label_Color = White;
int _sd = false;
int _ad08 = false;
int _ad04 = false;
int _ah08 = false;
int _ah04 = false;



int D1 = 1440;
int H4 = 240;
int H1 = 60;
int M30 =30;

int eintPeriod = 20;
double edblHigh1 = 0.4;
double edblLow1 = -0.4;
int atrPeriod = 100;
//29Έφ

string symbolName[] = { "ABCDEF","AUDJPY","AUDUSD","EURGBP","EURJPY","EURUSD","GBPJPY","GBPUSD","USDCHF","USDJPY","USDCAD",};
//put all these pairs on one line so that errors when compiling would direct you to the correct line.
double PowValue4H[29];
double PowValue1H[29];
double PowValue30M[29];
double dailyslope[29];
double H4slope[29];
double H1slope[29];
double M30slope[29];
datetime current_time;
int pivot_bar;
int line_thickness;

string timeframe_prefix, timeframe_prefix_text, pregap = "";
int pivot_timeframe_const = PERIOD_W1;

double P,S1,R1,S2,R2,S3,R3, MS1, MS2, MS3, MR1, MR2, MR3, dP,dS1,dR1,dS2,dR2,dS3,dR3;
double last_high,last_low,last_close;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
//---- indicators
	string SymbolSuffix = StringSubstr(Symbol(),6);// get Suffix of broker...
	for(int n=0; n<ArraySize(symbolName); n++) {// go through Symbol Names and append suffix..
		symbolName[n]=symbolName[n]+SymbolSuffix;
		Print(symbolName[n]);//print to journal
	}
	ObjectsDeleteAll(0);
//----
//Display titles---------------------
//	ObjectsDeleteAll(0);

	if (useCurrencyNameFilter && CurrencyNameFilter !="")
	createLable("t_symbol",CurrencyNameFilter,baseX*2,baseY,fontsize,Label_Color);
	else createLable("t_symbol","Symbol",baseX*2,baseY,fontsize,Label_Color);
	                             // symbols column label
	createLable("t_DD1",CharToStr(18),baseX,baseY,fontsize,Label_Color);// arrow column lable

	createLable("t_tma","TS(D1)",baseX+cellWidth+15,baseY,fontsize,Label_Color);
	createLable("t_TS4","(H4)",baseX+cellWidth*2+10,baseY,fontsize,Label_Color);              //slope column labels
	createLable("t_TS1","(H1)",baseX+cellWidth*2+70,baseY,fontsize,Label_Color);
	createLable("t_TS30","(M30)",baseX+cellWidth*3+50,baseY,fontsize,Label_Color);

	createLable("t_pow4","Pow(H4)",baseX+cellWidth*4+20,baseY,fontsize,Label_Color);
	createLable("t_pow1","(H1)",baseX+cellWidth*5+20,baseY,fontsize,Label_Color);     //Pow column labels
	createLable("t_pow30","(30M)",baseX+cellWidth*6+10,baseY,fontsize,Label_Color);

	//if(Last2BarsTouching4) 	createLable("t_Touch4","TP2(H4)",baseX+cellWidth*7,baseY,fontsize,Label_Color);
	//else                           createLable("t_Touch4","TP(H4)",baseX+cellWidth*7,baseY,fontsize,Label_Color);
	//if(Last2BarsTouching1) 	createLable("t_Touch1","TP2(H1)",baseX+cellWidth*8,baseY,fontsize,Label_Color); //touching pivots column labels.
	//else                           createLable("t_Touch1","TP(H1)",baseX+cellWidth*8,baseY,fontsize,Label_Color);
	//if(Last2BarsTouching30)createLable("t_Touch30","TP2(M30)",baseX+cellWidth*9,baseY,fontsize,Label_Color);
	//else                           createLable("t_Touch30","TP(M30)",baseX+cellWidth*9,baseY,fontsize,Label_Color);

	createLable("t_d","__________________________________________________________",baseX,baseY+10,fontsize,Label_Color);// limit on length
	createLable("t_d2","_______________________________________________",baseX+405,baseY+10,fontsize,Label_Color);// so I made two

	//--------------display titles end---------------------_

	
	return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {
//----
	ObjectsDeleteAll(0);
//----
	return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() 
{

//----
string sn= "";
	int i = 0;
	int j = 0;
	int k = 0;
	int l = 0;
	int m = 0;

//--------------dis

	if (SortByPow && !SortBySlope) {//start loop that sorts the pairs by pow number
		for(i=0; i<ArraySize(symbolName); i++) {

			sn = symbolName[i];
			if(MarketInfo(sn,MODE_SPREAD)<=0) continue;
			if(useCurrencyNameFilter && CurrencyNameFilter !="") 
				if(StringFind(sn,CurrencyNameFilter)<0) continue;// skip this one if it doesn't contain your currency filter's name
		
			PowValue4H[i] = getPow(sn,240);
			PowValue1H[i] = getPow(sn,60);
			PowValue30M[i] = getPow(sn,30);
		}

		double t = 0;
		double s = 0;
		double u = 0;
		string st = "";
		string uv = "";
		string wx = "";
			for(i=ArraySize(symbolName)-1; i>0; i--) {
				if(Choice == 240){
					for(j=0; j<i; j++) {
						//4Hour values.
						if(UseAbslouteValues){
							if(MathAbs(PowValue4H[j])<MathAbs(PowValue4H[j+1])){	//if this pair has less value than next on below in list.
								t = PowValue4H[j];																// store this lesser pair's value in t
								PowValue4H[j]=PowValue4H[j+1];										//copy greater value from pair below and move it up one space from j+1 to j
								PowValue4H[j+1] = t;															//take stored lesser pair's power and move it down one space from j to j+1
								// effectively swapping places.... now for the label swap...........
								st = symbolName[j];															// copy stringname of j to st
								symbolName[j]=symbolName[j+1];										//put j+1's name where j's was
								symbolName[j+1] = st;														// put j's name where j+1's was....
								// now we have moved the value and the label both up one space in the buffers[]
							}
						}
						else{
							if(PowValue4H[j]<PowValue4H[j+1]){	//if this pair has less value than next on below in list.
								t = PowValue4H[j];																// store this lesser pair's value in t
								PowValue4H[j]=PowValue4H[j+1];										//copy greater value from pair below and move it up one space from j+1 to j
								PowValue4H[j+1] = t;															//take stored lesser pair's power and move it down one space from j to j+1
								// effectively swapping places.... now for the label swap...........
								st = symbolName[j];															// copy stringname of j to st
								symbolName[j]=symbolName[j+1];										//put j+1's name where j's was
								symbolName[j+1] = st;														// put j's name where j+1's was....
								// now we have moved the value and the label both up one space in the buffers[]
							}
						}
					}
				}
			
				if(Choice == 60){
					for(l=0; l<i; l++) {
						//1Hour values.
						if(UseAbslouteValues){
							if(MathAbs(PowValue1H[l])<MathAbs(PowValue1H[l+1])) {

							s = PowValue1H[l];
							PowValue1H[l]=PowValue1H[l+1];
							PowValue1H[l+1] = s;

							uv = symbolName[l];
							symbolName[l]=symbolName[l+1];
							symbolName[l+1] = uv;
							}
						}
						else{
								if(PowValue1H[l]<PowValue1H[l+1]) {

								s = PowValue1H[l];
								PowValue1H[l]=PowValue1H[l+1];
								PowValue1H[l+1] = s;

								uv = symbolName[l];
								symbolName[l]=symbolName[l+1];
								symbolName[l+1] = uv;
								}
							}
					}
				}	
				// sorting 30m pairs by pow
				if(Choice == 30){	
					for(m=0; m<i; m++) {
						if(UseAbslouteValues){
							if(MathAbs(PowValue30M[m])<MathAbs(PowValue30M[m+1])) {

								u = PowValue30M[m];
								PowValue30M[m]=PowValue30M[m+1];
								PowValue30M[m+1] = u;

								wx = symbolName[m];
								symbolName[m]=symbolName[m+1];
								symbolName[m+1] = wx;

							}
						}
						else{
							if(PowValue30M[m]<PowValue30M[m+1]) {

								u = PowValue30M[m];
								PowValue30M[m]=PowValue30M[m+1];
								PowValue30M[m+1] = u;
	
								wx = symbolName[m];
								symbolName[m]=symbolName[m+1];
								symbolName[m+1] = wx;
							}	
						}	
					}	
				}
			}
	}//end sort by pow

		if(SortBySlope && !SortByPow){
			for(i=0; i<ArraySize(symbolName); i++) {
				sn = symbolName[i];
				dailyslope[i] = getTmaSlope(sn,D1);
				H4slope[i] = getTmaSlope(sn,H4);
				H1slope[i] = getTmaSlope(sn,H1);
				M30slope[i] = getTmaSlope(sn,M30);
				
			}
			
			int x=0;
			string xy=0;
		
			if(Choice==1440){
			for(i=ArraySize(symbolName)-1; i>0; i--) {
				for(j=0; j<i; j++) {
					if( dailyslope[j] < dailyslope[j+1] ){
							x = dailyslope[j];
							dailyslope[j]=dailyslope[j+1];
							dailyslope[j+1] = t;
					
							xy = symbolName[j];
							symbolName[j]=symbolName[j+1];
							symbolName[j+1] = xy;
						}
					}
				}
			}
			
			if(Choice==240){
			for(i=ArraySize(symbolName)-1; i>0; i--) {
				for(j=0; j<i; j++) {
					if( H4slope[j] < H4slope[j+1] ){
							x = H4slope[j];
							H4slope[j]=H4slope[j+1];
							H4slope[j+1] = t;
						
							xy = symbolName[j];
							symbolName[j]=symbolName[j+1];
							symbolName[j+1] = xy;
						}
					}
				}
			}
			
			if(Choice==60){
			for(i=ArraySize(symbolName)-1; i>0; i--) {
				for(j=0; j<i; j++) {
					if( H1slope[j] < H1slope[j+1] ){
							x = H1slope[j];
							H1slope[j]=H1slope[j+1];
							H1slope[j+1] = t;
						
							xy = symbolName[j];
							symbolName[j]=symbolName[j+1];
							symbolName[j+1] = xy;
						}
					}
				}
			}
			
			if(Choice==30){
			for(i=ArraySize(symbolName)-1; i>0; i--) {
				for(j=0; j<i; j++) {
					if( M30slope[j] < M30slope[j+1] ){
							x = M30slope[j];
							M30slope[j]=M30slope[j+1];
							M30slope[j+1] = t;
						
							xy = symbolName[j];
							symbolName[j]=symbolName[j+1];
							symbolName[j+1] = xy;
						}
					}
				}
			}
		}




	for (i = 0; i<ArraySize(symbolName); i++) {													// loop thru all the pairs and get info

		sn = symbolName[i];					// start with first pair.... this loop will run all the way thru once for each currency pair and get info

		if(MarketInfo(symbolName[i],MODE_SPREAD)<=0) continue;// currency pair shows now spread ..skip it.
		if(useCurrencyNameFilter && CurrencyNameFilter !="") 
			if(StringFind(sn,CurrencyNameFilter)<0) continue;// skip this one if it doesn't contain your currency filter's name
		
		double hh_d1 = getTmaSlope(sn,D1);														//get daily slope
		string jj_d1=DoubleToStr(hh_d1,2);															//change to string
	
		double hh_h4 = getTmaSlope(sn,H4);														// get 4h slope
		string jj_h4=DoubleToStr(hh_h4,2);															// change to string

		double hh_h1 = getTmaSlope(sn,H1);														//get 1h slope
		string jj_h1=DoubleToStr(hh_h1,2);															//change to string

		double hh_m30 = getTmaSlope(sn,M30);//get 1h slope
		string jj_m30=DoubleToStr(hh_m30,2);//change to string
		
		





		if(hh_h4 != 0 && hh_d1 != 0 )
			if(SameDirection && (hh_h4/hh_d1<0)) continue;// skip if not same direction
		if(hh_h1 != 0 && hh_d1 != 0 )
			if(SameDirection && (hh_h1/hh_d1<0)) continue;// skip if not same direction
		if(hh_m30 != 0 && hh_d1 != 0 )
			if(SameDirection && (hh_m30/hh_d1<0)) continue;// skip if not same direction
		

		double p,r1,s1,r2,s2,r3,s3;
		getPivot(sn,p,r1,s1,r2,s2,r3,s3);						//calls get pivot function to get all the pivot info for whateve pair this trip thru the loop is for..


		string dir = "";
		color c_d1 = inside_4;// starts off Light Gray
		if(hh_d1>0) {dir=CharToStr(228);} //up arrow
		if(hh_d1<0) {dir=CharToStr(230);} //down arrow
		if(hh_d1>=0.4) {c_d1=above_4;}      // change inside_4 if over 0.4                             //establish colors and characters for Daily signals
		if(hh_d1>=0.8) {c_d1=above_8;}        //change to above_8 if over 0.8
		if(hh_d1<=-0.4) {c_d1=below_4;} //change to below_4 if under 0.4
		if(hh_d1<=-0.8) c_d1=below_8;           //change to below_8 if under 0.8

		color c_h4 = inside_4;
		if(hh_h4>=0.4) {c_h4=above_4;}                                                    //establish colors and characters for 4H signals
		if(hh_h4>=0.8) {c_h4=above_8;}
		if(hh_h4<=-0.4) {c_h4=below_4;}
		if(hh_h4<=-0.8) c_h4=below_8;

		color c_h1 = inside_4;
		if(hh_h1>=0.4) {c_h1=above_4;}         //establish colors and characters for 1H signals
		if(hh_h1>=0.8) {c_h1=above_8;}
		if(hh_h1<=-0.4) {c_h1=below_4;}
		if(hh_h1<=-0.8) c_h1=below_8;

		color c_m30 = inside_4;
		if(hh_m30>=0.4) {c_m30=above_4;}         //establish colors and characters for 1H signals
		if(hh_m30>=0.8) {c_m30=above_8;}
		if(hh_m30<=-0.4) {c_m30=below_4;}
		if(hh_m30<=-0.8) c_m30=below_8;

		double pow4 = getPow(sn,240);
		double pow1 = getPow(sn,60);
		double pow30 = getPow(sn,30);

		color c_pow4 = inside_4;
		if(pow4>0) c_pow4 = above_4;
		if(pow4<0) c_pow4 = below_4;

		color c_pow1 = inside_4;
		if(pow1>0) c_pow1 = above_4;
		if(pow1<0) c_pow1 = below_4;

		color c_pow30 = inside_4;
		if(pow30>0) c_pow30 = above_4;
		if(pow30<0) c_pow30 = below_4;

		string str_pow4 = DoubleToStr(pow4,2);
		if ((pow4*hh_d1)>0) {
			str_pow4 = str_pow4+"*";
			if(pow4>0) c_pow4 = above_8;
			if(pow4<0) c_pow4= below_8;
		}

		string str_pow1 = DoubleToStr(pow1,2);
		if ((pow1*hh_d1)>0) {
			str_pow1 = str_pow1+"*";
			if(pow1>0) c_pow1 = above_8;
			if(pow1<0) c_pow1 = below_8;
		}

		string str_pow30 = DoubleToStr(pow30,2);
		if ((pow30*hh_d1)>0) {
			str_pow30 = str_pow30+"*";
			if(pow30>0) c_pow30 = above_8;
			if(pow30<0) c_pow30 = below_8;
		}

		sn = symbolName[i];
		string touch_pivots4 = "";
		if(Last2BarsTouching4) {
			if(iHigh(sn,PERIOD_H4,1) >= p && iLow(sn,PERIOD_H4,1) <= p) touch_pivots4 = "P";
			if(iHigh(sn,PERIOD_H4,1) >= s1 && iLow(sn,PERIOD_H4,1) <= s1) touch_pivots4 = "S1";
			if(iHigh(sn,PERIOD_H4,1) >= r1 && iLow(sn,PERIOD_H4,1) <= r1) touch_pivots4 = "R1";
			if(iHigh(sn,PERIOD_H4,1) >= r2 && iLow(sn,PERIOD_H4,1) <= r2) touch_pivots4 = "R2";
			if(iHigh(sn,PERIOD_H4,1) >= s2 && iLow(sn,PERIOD_H4,1) <= s2) touch_pivots4 = "S2";
			if(iHigh(sn,PERIOD_H4,1) >= r3 && iLow(sn,PERIOD_H4,1) <= r3) touch_pivots4 = "R3";
			if(iHigh(sn,PERIOD_H4,1) >= s3 && iLow(sn,PERIOD_H4,1) <= s3) touch_pivots4 = "S3";
		}

		if(iHigh(sn,PERIOD_H4,0) >= p && iLow(sn,PERIOD_H4,0) <= p) touch_pivots4 = "P";
		if(iHigh(sn,PERIOD_H4,0) >= s1 && iLow(sn,PERIOD_H4,0) <= s1) touch_pivots4 = "S1";
		if(iHigh(sn,PERIOD_H4,0) >= r1 && iLow(sn,PERIOD_H4,0) <= r1) touch_pivots4 = "R1";
		if(iHigh(sn,PERIOD_H4,0) >= r2 && iLow(sn,PERIOD_H4,0) <= r2) touch_pivots4 = "R2";
		if(iHigh(sn,PERIOD_H4,0) >= s2 && iLow(sn,PERIOD_H4,0) <= s2) touch_pivots4 = "S2";
		if(iHigh(sn,PERIOD_H4,0) >= r3 && iLow(sn,PERIOD_H4,0) <= r3) touch_pivots4 = "R3";
		if(iHigh(sn,PERIOD_H4,0) >= s3 && iLow(sn,PERIOD_H4,0) <= s3) touch_pivots4 = "S3";

		string touch_pivots1 = "";
		if(Last2BarsTouching1) {
			if(iHigh(sn,PERIOD_H1,1) >= p && iLow(sn,PERIOD_H1,1) <= p) touch_pivots1 = "P";
			if(iHigh(sn,PERIOD_H1,1) >= s1 && iLow(sn,PERIOD_H1,1) <= s1) touch_pivots1 = "S1";
			if(iHigh(sn,PERIOD_H1,1) >= r1 && iLow(sn,PERIOD_H1,1) <= r1) touch_pivots1 = "R1";
			if(iHigh(sn,PERIOD_H1,1) >= r2 && iLow(sn,PERIOD_H1,1) <= r2) touch_pivots1 = "R2";
			if(iHigh(sn,PERIOD_H1,1) >= s2 && iLow(sn,PERIOD_H1,1) <= s2) touch_pivots1 = "S2";
			if(iHigh(sn,PERIOD_H1,1) >= r3 && iLow(sn,PERIOD_H1,1) <= r3) touch_pivots1 = "R3";
			if(iHigh(sn,PERIOD_H1,1) >= s3 && iLow(sn,PERIOD_H1,1) <= s3) touch_pivots1 = "S3";
		}

		if(iHigh(sn,PERIOD_H1,0) >= p && iLow(sn,PERIOD_H1,0) <= p) touch_pivots1 = "P";
		if(iHigh(sn,PERIOD_H1,0) >= s1 && iLow(sn,PERIOD_H1,0) <= s1) touch_pivots1 = "S1";
		if(iHigh(sn,PERIOD_H1,0) >= r1 && iLow(sn,PERIOD_H1,0) <= r1) touch_pivots1 = "R1";
		if(iHigh(sn,PERIOD_H1,0) >= r2 && iLow(sn,PERIOD_H1,0) <= r2) touch_pivots1 = "R2";
		if(iHigh(sn,PERIOD_H1,0) >= s2 && iLow(sn,PERIOD_H1,0) <= s2) touch_pivots1 = "S2";
		if(iHigh(sn,PERIOD_H1,0) >= r3 && iLow(sn,PERIOD_H1,0) <= r3) touch_pivots1 = "R3";
		if(iHigh(sn,PERIOD_H1,0) >= s3 && iLow(sn,PERIOD_H1,0) <= s3) touch_pivots1 = "S3";

		string touch_pivots30 = "";
		if(Last2BarsTouching30) {
			if(iHigh(sn,30,1) >= p && iLow(sn,30,1) <= p) touch_pivots30 = "P";
			if(iHigh(sn,30,1) >= s1 && iLow(sn,30,1) <= s1) touch_pivots30 = "S1";
			if(iHigh(sn,30,1) >= r1 && iLow(sn,30,1) <= r1) touch_pivots30 = "R1";
			if(iHigh(sn,30,1) >= r2 && iLow(sn,30,1) <= r2) touch_pivots30 = "R2";
			if(iHigh(sn,30,1) >= s2 && iLow(sn,30,1) <= s2) touch_pivots30 = "S2";
			if(iHigh(sn,30,1) >= r3 && iLow(sn,30,1) <= r3) touch_pivots30 = "R3";
			if(iHigh(sn,30,1) >= s3 && iLow(sn,30,1) <= s3) touch_pivots30 = "S3";
		}

		if(iHigh(sn,30,0) >= p && iLow(sn,30,0) <= p) touch_pivots30 = "P";
		if(iHigh(sn,30,0) >= s1 && iLow(sn,30,0) <= s1) touch_pivots30 = "S1";
		if(iHigh(sn,30,0) >= r1 && iLow(sn,30,0) <= r1) touch_pivots30 = "R1";
		if(iHigh(sn,30,0) >= r2 && iLow(sn,30,0) <= r2) touch_pivots30 = "R2";
		if(iHigh(sn,30,0) >= s2 && iLow(sn,30,0) <= s2) touch_pivots30 = "S2";
		if(iHigh(sn,30,0) >= r3 && iLow(sn,30,0) <= r3) touch_pivots30 = "R3";
		if(iHigh(sn,30,0) >= s3 && iLow(sn,30,0) <= s3) touch_pivots30 = "S3";


		//==================filters=======================

		
		if(TouchPivots4 && touch_pivots4 =="") continue;//skipe if no pivot being touched
		if(TouchPivots1 && touch_pivots1 =="") continue;//skipe if no pivot being touched
		if(TouchPivots30 && touch_pivots30 =="") continue;//skipe if no pivot being touched

		if(NoP && touch_pivots4 =="P") continue;//skip if pivot not being touched
		if(NoP && touch_pivots1 =="P") continue;//skip if pivot not being touched
		if(NoP && touch_pivots30 =="P") continue;//skip if pivot not being touched

		if(NoS1R1 && (touch_pivots4 =="S1" || touch_pivots4 =="R1")) continue;//skip if R1 not being touched

		if(NoS2R2 && (touch_pivots4 =="S2" || touch_pivots4 =="R2")) continue;//skip if R2 not being touched

		if(NoS3R3 && (touch_pivots4 =="S3" || touch_pivots4 =="R3")) continue;//skip if R3 not being touched

		if(D1_08 && MathAbs(hh_d1) < 0.8 ) continue;// skip if not over 0.8

		if(D1_04 && MathAbs(hh_d1) < 0.4 ) continue;// skip if not over 0.4

		if(H4_08 && MathAbs(hh_h4) < 0.8 ) continue;// skip if not over 0.8

		if(H4_04 && MathAbs(hh_h4) < 0.4 ) continue;// skip if not over 0.4

		if(H1_08 && MathAbs(hh_h1) < 0.8 ) continue;// skip if not over 0.8

		if(H1_04 && MathAbs(hh_h1) < 0.4 ) continue;// skip if not over 0.4

		if(M30_08 && MathAbs(hh_m30) < 0.8 ) continue;// skip if not over 0.8

		if(M30_04 && MathAbs(hh_m30) < 0.4 ) continue;// skip if not over 0.4

//==================filters end=======================


		createLable("symbol_"+sn,sn,baseX+15,baseY+cellHeight*(k+2),fontsize,c_d1);
		createLable("ts_"+sn,jj_d1,baseX+cellWidth+32,baseY+cellHeight*(k+2),fontsize,c_d1);
		createLable("dir_d1"+sn,dir,baseX,baseY+cellHeight*(k+2),fontsize,c_d1,"Wingdings");
		createLable("ts_h4"+sn,jj_h4,baseX+cellWidth*2+10,baseY+cellHeight*(k+2),fontsize,c_h4);
		createLable("ts_h1"+sn,jj_h1,baseX+cellWidth*2+70,baseY+cellHeight*(k+2),fontsize,c_h1);
		createLable("ts_m30"+sn,jj_m30,baseX+cellWidth*3+50,baseY+cellHeight*(k+2),fontsize,c_m30);
		createLable("power_h4"+sn,str_pow4,baseX+cellWidth*4+40,baseY+cellHeight*(k+2),fontsize,c_pow4);
		createLable("power_h1"+sn,str_pow1,baseX+cellWidth*5+20,baseY+cellHeight*(k+2),fontsize,c_pow1);
		createLable("power_m30"+sn,str_pow30,baseX+cellWidth*6+10,baseY+cellHeight*(k+2),fontsize,c_pow30);
		createLable("pivo_h4"+sn,touch_pivots4,baseX+cellWidth*7,baseY+cellHeight*(k+2),fontsize,c_h4);
		createLable("pivo_h1"+sn,touch_pivots1,baseX+cellWidth*8,baseY+cellHeight*(k+2),fontsize,c_h1);
		createLable("pivo_m30"+sn,touch_pivots30,baseX+cellWidth*9,baseY+cellHeight*(k+2),fontsize,c_m30);
		k++;

	}


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

//+------------------------------------------------------------------+
double getPow(string sn,int tf) {
	int k = 0;
	double total_power = 0;
	double average_power = 0;
	
	for(k=0; k<30; k++) {// do this loop 30 time 0-29
		total_power+=iVolume(sn,tf,k);//add together all the tick volume for candles 0-29
	}
	average_power = total_power/30;// divide that total volume by 30 to get the average

	if(average_power==0 || iOpen(sn,tf,0)-1 ==0) return(0);// if after all this it comes up with zero... then you don't have any data... cancel this operation
	if(ReSortEveryTick) double close = iClose(sn,1,0);else close =iClose(sn,1,1);
	double pow = (iVolume(sn,tf,0)/average_power) *10000* (close/ iOpen(sn,tf,0)-1);
	/*	it takes the volume of the current candle which is constantly increasing lets say its 100...
		divides it by the average power of the last 30 candles... we'll say 200 so thats 100/200 = .5 
		So volume is half of normal ...then it mulitplies it by 10,000 leaving 5000....
		5000 * (current price /current open price)-1)... let's say price went up (1.2500/1.2450)-1) =.004... 4/10ths of a  percent  
		5000 * .004 = Power of 20 if price rose .4 percent  at half normal volume.....if price went down 5000 * -.004 = -20
		If volume was double of normal (400) and price only went up .4% ....= 20,000 * .004 = 80 Power or price down would be  -80 Power
		So you can see it took many more ticks (Power) to move market same amount.. 400 instead of 100 
		it required much more POWER. Grunting along..... If it had moved price 1.6 Percent with this quadrupling in tick volume. 
		In other words it gained 200 pips instead of 50 pips.Then it would have been	(1.2650/1.2450)-1)=.016 * 20,000=320
		What if volume is absolutely normal? 100/100 =10,000 X .004 = 40.....ok so what if volume stays constant but price amount price moved 
		is more than 50 pips.
	
	
	
	*/
	return (pow);
}

void createLable(string name,string text,int x,int y,int size,color c,string font = "Arial") {
	name = name + LabelCorner;
	ObjectCreate(name, OBJ_LABEL,0,0,0);
	ObjectSet(name, OBJPROP_CORNER, LabelCorner);
	ObjectSet(name, OBJPROP_XDISTANCE, x);// X coordinate
	ObjectSet(name, OBJPROP_YDISTANCE, y);// Y coordinate
	ObjectSetText(name,text,size,font,c);

}

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

double calcTmaMTF( int inx ,int tf,string symbol) {
	double dblSum  = (eintPeriod+1)*iClose(symbol,tf,inx);
	double dblSumw = (eintPeriod+1);
	int jnx, knx;

	for ( jnx = 1, knx = eintPeriod; jnx <= eintPeriod; jnx++, knx-- ) {
		dblSum  += ( knx * iClose(symbol,tf,inx+jnx) );
		dblSumw += knx;

		if ( jnx <= inx ) {
			dblSum  += ( knx * iClose(symbol,tf,inx-jnx) );
			dblSumw += knx;
		}
	}
	if (dblSumw==0) return (0);
	return( dblSum / dblSumw );
}

double getTmaSlope(string symbol,int tf) {
//	double dblTma, //dblPrev;
	double dblTmaMTF, dblPrevMTF;
//	double atr ;
	double atrMTF ;

	atrMTF= iATR(symbol,tf,atrPeriod,0+10)*0.1;
	dblTmaMTF = calcTmaMTF( 0 , tf ,symbol);
	dblPrevMTF = calcTmaMTF( 1 , tf, symbol);

	if(atrMTF ==0) return(0);
	double hh = ( dblTmaMTF - dblPrevMTF ) / atrMTF;

	return(hh);
}

void getPivot(string symbol,double &pivot,double &r1,double &s1,double &r2,double &s2, double &r3, double &s3) {
	current_time = Time[0];
	// and seach the corresponding bar in the pivot timeframe
	pivot_bar = iBarShift( symbol, pivot_timeframe_const, current_time);
	// read the values of that previous week/month
	last_low=iLow(symbol, pivot_timeframe_const, pivot_bar+1);
	last_high=iHigh(symbol, pivot_timeframe_const, pivot_bar+1);
	last_close=iClose(symbol, pivot_timeframe_const, pivot_bar+1);

	// calculate main pivot and S/R lines
	//P=(last_high+last_low+last_close)/3;
	//R1=(2*P)-last_low;
	//S1=(2*P)-last_high;
	//R2=P+(last_high-last_low);
	//S2=P-(last_high-last_low);
	//R3=(2*P)+(last_high-(2*last_low));
	//S3=(2*P)-((2*last_high)-last_low);

	// calculate mid S/R lines
	//MS3 = S3 + ((S2-S3) / 2);
	//MS2 = S2 + ((S1-S2) / 2);
	//MS1 = S1 + ((P-S1) / 2);
	//MR1 = P + ((R1-P) / 2);
	//MR2 = R1 + ((R2-R1) / 2);
	//MR3 = R2 + ((R3-R2) / 2);

	// copy either main or mid values to the temp display variables

	dP=P;
	dS1=S1;
	dR1=R1;
	dS2=S2;
	dR2=R2;
	dS3=S3;
	dR3=R3;

	pivot = dP;
	r1 = dR1;
	s1 = dS1;
	r2 = dR2;
	s2 = dS2;
	r3 = dR3;
	s3 = dS3;

}

