//+------------------------------------------------------------------+ 
//|   TRO_Multi_Meter_FXWealth                                       | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| go to www.kreslik.com for the latest indicator updates           |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| Use http://therumpledone.mbtrading.com/fx/ as your forex broker  |  
//| ...tell them therumpledone sent you!                             |  
//+------------------------------------------------------------------+  

// http://www.forex-tsd.com/expert-advisors-metatrader-4/16184-successful-manual-system-ea-needed-please.html 

#property indicator_chart_window

extern bool Show_Heading = true;
 
extern string IndName = "Wealth" ; // change

extern bool Corner_of_Chart_RIGHT_TOP = true;

extern int Shift_UP_DN =0; 
extern int Adjust_Side_to_side  = 20; // 20

extern color BarLabel_color     = DimGray;
extern color CommentLabel_color = DimGray;

extern color UpS_color = Lime;
extern color UpW_color = Green;
extern color Eq_color  = Yellow;
extern color DnW_color = Maroon;
extern color DnS_color = Red;


// change inputs for your indicator 

//#define PRICE_HA 7
   extern string _        = "Parameters";
   extern int    iPerioda = 144;
   extern int    iPricea  = PRICE_TYPICAL;
   extern int    iPeriodb =  21;
   extern int    iPriceb  = 7;


 

//*******************

string ObjHead01,ObjHead02,ObjHead03,ObjHead04,ObjHead05,ObjHead06,ObjHead07,ObjHead08,ObjHead09,ObjHead10,ObjHead11;  

string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009,Obj0010,Obj0011;  

string symbol, tChartPeriod,  tShortName ;  
int    digits, period  ; 

string LabelTime="";

   string Wealth_ObjHead01 ="M1 " ;
   string Wealth_ObjHead02 ="M5  " ;     
   string Wealth_ObjHead03 ="M15 " ;
   string Wealth_ObjHead04 =" M30 " ;
   string Wealth_ObjHead05 ="H1  " ;     
   string Wealth_ObjHead06 ="H4  " ;
   string Wealth_ObjHead07 ="D1  " ;
   string Wealth_ObjHead08 ="W1  " ;
   string Wealth_ObjHead09 ="MN1" ;   


double Wealth_Open, Wealth_Close, Wealth_High, Wealth_Low, Wealth_Diff, Wealth_Mid, Wealth_Pivot,cWealth_Value,pWealth_Value ;

//+---------------
color prDiff(int TimeFrame, int j)
{
  color _color = Yellow ;

   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame

   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);  
   
   limit=1;     
   
   for(i=0,y=0;i<limit;i++)
   {
 
      if (Time[i]<TimeArray[y]) y++;   

      cWealth_Value = iCustom(symbol,TimeFrame,"ZeroLag Tema 2",iPerioda,iPricea,iPeriodb,iPriceb,0,y);
      pWealth_Value = iCustom(symbol,TimeFrame,"ZeroLag Tema 2",iPerioda,iPricea,iPeriodb,iPriceb,0,y+1); 


   } // for 



      Wealth_Close   = iClose(NULL,TimeFrame,j) ;            // close of the chart period
      Wealth_Open    = iOpen(NULL,TimeFrame,j) ;    // open of the Wealth period  
      Wealth_High    = iHigh(NULL,TimeFrame,j+1) ;    // high of the Wealth period + 1
      Wealth_Low     = iLow(NULL,TimeFrame,j+1) ;     // low of the Wealth period + 1
  
      Wealth_Diff    = Wealth_Close - Wealth_Open ;
 
      Wealth_Mid     = ( Wealth_High + Wealth_Low ) * 0.50 ;
      Wealth_Mid     = NormalizeDouble( Wealth_Mid , digits ) ; 




       
   while(true)
   {
   if (Wealth_Diff > 0 && Wealth_Close > Wealth_Mid ) { _color = UpS_color ; break; } // strong up
   if (Wealth_Diff > 0 && Wealth_Close < Wealth_Mid ) { _color = UpW_color ; break; } // weak up
   if (Wealth_Diff < 0 && Wealth_Close > Wealth_Mid ) { _color = DnW_color ; break; } // weak down
   if (Wealth_Diff < 0 && Wealth_Close < Wealth_Mid ) { _color = DnS_color ; break; } // strong down
                                                  _color = Eq_color  ; break;   // no Wealth
   } 
   
   
  return (_color);
}

//+------------------------------------------------------------------+
int init()
  {
//---- 
   period       = Period() ;   
   tChartPeriod = TimeFrameToString(period) ;
   symbol       = Symbol() ;
   LabelTime    = symbol + tChartPeriod  ;  

   ObjHead01 = "WealthColHead01"  ; 
   ObjHead02 = "WealthColHead02"  ; 
   ObjHead03 = "WealthColHead03"  ; 
   ObjHead04 = "WealthColHead04"  ; 
   ObjHead05 = "WealthColHead05"  ; 
   ObjHead06 = "WealthColHead06"  ; 
   ObjHead07 = "WealthColHead07"  ; 
   ObjHead08 = "WealthColHead08"  ; 
   ObjHead09 = "WealthColHead09"  ; 

   Obj0002 = "WealthSignalM1t" ; 
   Obj0003 = "WealthSignalM1" ;  
   Obj0004 = "WealthSignalM5" ;  
   Obj0005 = "WealthSignalM15" ;    
   Obj0006 = "WealthSignalM30" ;    
   Obj0007 = "WealthSignalM60" ;     
   Obj0008 = "WealthSignalM240" ;   
   Obj0009 = "WealthSignalM1440" ;   
   Obj0010 = "WealthSignalW1" ;  
   Obj0011 = "WealthSignalMN1" ;      
          
deleteObject() ;  
   
//----
   return(0);
  }


//+------------------------------------------------------------------+
int start()
{    

 
        
    if (Corner_of_Chart_RIGHT_TOP == true)
    { int Col01x = 170+Adjust_Side_to_side ;                 
      int Col01y = 28+Shift_UP_DN ;
    }
    if (Corner_of_Chart_RIGHT_TOP == false)
   { Col01x = 159+Adjust_Side_to_side ;       
     Col01y = 24+Shift_UP_DN ;
    } 
    
   int ColAdj = -20 ; 
   int Col02x = Col01x + ColAdj ;   
   int Col03x = Col01x + ColAdj*2 ; 
   int Col04x = Col01x + ColAdj*3 ; 
   int Col05x = Col01x + ColAdj*4 ; 
   int Col06x = Col01x + ColAdj*5 ; 
   int Col07x = Col01x + ColAdj*6 ;    
   int Col08x = Col01x + ColAdj*7 ; 
   int Col09x = Col01x + ColAdj*8 ;     
   
   if ( Show_Heading) {        
   
   ObjectCreate(ObjHead01, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead01,Wealth_ObjHead01 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead01, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead01, OBJPROP_XDISTANCE, Col01x);
   ObjectSet(ObjHead01, OBJPROP_YDISTANCE, Col01y); 

   ObjectCreate(ObjHead02, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead02,Wealth_ObjHead02 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead02, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead02, OBJPROP_XDISTANCE, Col02x);
   ObjectSet(ObjHead02, OBJPROP_YDISTANCE, Col01y);   
       
   ObjectCreate(ObjHead03, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead03,Wealth_ObjHead03 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead03, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead03, OBJPROP_XDISTANCE, Col03x);
   ObjectSet(ObjHead03, OBJPROP_YDISTANCE, Col01y); 
 
   ObjectCreate(ObjHead04, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead04,Wealth_ObjHead04 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead04, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead04, OBJPROP_XDISTANCE, Col04x);
   ObjectSet(ObjHead04, OBJPROP_YDISTANCE, Col01y); 
   
   ObjectCreate(ObjHead05, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead05,Wealth_ObjHead05 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead05, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead05, OBJPROP_XDISTANCE, Col05x);
   ObjectSet(ObjHead05, OBJPROP_YDISTANCE, Col01y); 
            
   ObjectCreate(ObjHead06, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead06,Wealth_ObjHead06 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead06, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead06, OBJPROP_XDISTANCE, Col06x);
   ObjectSet(ObjHead06, OBJPROP_YDISTANCE, Col01y); 

   ObjectCreate(ObjHead07, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead07,Wealth_ObjHead07 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead07, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead07, OBJPROP_XDISTANCE, Col07x);
   ObjectSet(ObjHead07, OBJPROP_YDISTANCE, Col01y); 
         
   ObjectCreate(ObjHead08, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead08,Wealth_ObjHead08 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead08, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead08, OBJPROP_XDISTANCE, Col08x);
   ObjectSet(ObjHead08, OBJPROP_YDISTANCE, Col01y); 

   ObjectCreate(ObjHead09, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(ObjHead09,Wealth_ObjHead09 , 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(ObjHead09, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(ObjHead09, OBJPROP_XDISTANCE, Col09x);
   ObjectSet(ObjHead09, OBJPROP_YDISTANCE, Col01y); 
       
} // Show_Heading
 
 
    
    string M1_Wealth= "-",M5_Wealth= "-", M15_Wealth= "-", M30_Wealth= "-", H1_Wealth= "-", H4_Wealth= "-", D1_Wealth= "-",PRC1, W1_Wealth= "-", MN1_Wealth= "-";

    color  color_Wealthm1,color_Wealthm5,color_Wealthm15,color_Wealthm30,color_WealthH1,color_WealthH4,color_WealthD1,color_WealthW1,color_WealthMN1;     
         

   //Wealth Signals

 
    color_Wealthm1  = prDiff( PERIOD_M1, 0 );
    color_Wealthm5  = prDiff( PERIOD_M5, 0 );
    color_Wealthm15 = prDiff( PERIOD_M15, 0 );
    color_Wealthm30 = prDiff( PERIOD_M30, 0 );
    color_WealthH1  = prDiff( PERIOD_H1, 0 );
    color_WealthH4  = prDiff( PERIOD_H4, 0 ); 
    color_WealthD1  = prDiff( PERIOD_D1, 0 );
    color_WealthW1  = prDiff( PERIOD_W1, 0 );
    color_WealthMN1 = prDiff( PERIOD_MN1, 0 );
 
  
             
    
 //*******************          
    
    int Col00x = Col01x + 20 ;
    int Col00y = 50+Shift_UP_DN ;
    
    Col01y = 20+Shift_UP_DN ;

             
           ObjectCreate(Obj0002, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0002,IndName, 7, "Tahoma Narrow",  BarLabel_color);  
   ObjectSet(Obj0002, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0002, OBJPROP_XDISTANCE, Col00x);
   ObjectSet(Obj0002, OBJPROP_YDISTANCE, Col00y);  // 50+Shift_UP_DN

      
           ObjectCreate(Obj0003, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0003, M1_Wealth, 40, "Tahoma Narrow",  color_Wealthm1);
   ObjectSet(Obj0003, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0003, OBJPROP_XDISTANCE, Col01x);
   ObjectSet(Obj0003, OBJPROP_YDISTANCE, Col01y); 

          
           ObjectCreate(Obj0004, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0004, M5_Wealth, 40, "Tahoma Narrow",  color_Wealthm5);
   ObjectSet(Obj0004, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0004, OBJPROP_XDISTANCE, Col02x);
   ObjectSet(Obj0004, OBJPROP_YDISTANCE, Col01y); 
      

   ObjectCreate(Obj0005, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0005, M15_Wealth, 40, "Tahoma Narrow",  color_Wealthm15);
   ObjectSet(Obj0005, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0005, OBJPROP_XDISTANCE, Col03x);
   ObjectSet(Obj0005, OBJPROP_YDISTANCE, Col01y); 
      

   ObjectCreate(Obj0006, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0006, M30_Wealth, 40, "Tahoma Narrow",  color_Wealthm30);
   ObjectSet(Obj0006, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0006, OBJPROP_XDISTANCE, Col04x);
   ObjectSet(Obj0006, OBJPROP_YDISTANCE, Col01y); 

    
           ObjectCreate(Obj0007, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0007, H1_Wealth, 40, "Tahoma Narrow",  color_WealthH1);
   ObjectSet(Obj0007, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0007, OBJPROP_XDISTANCE, Col05x);
   ObjectSet(Obj0007, OBJPROP_YDISTANCE, Col01y); 

          
           ObjectCreate(Obj0008, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0008, H4_Wealth, 40, "Tahoma Narrow",  color_WealthH4);
   ObjectSet(Obj0008, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0008, OBJPROP_XDISTANCE, Col06x);
   ObjectSet(Obj0008, OBJPROP_YDISTANCE, Col01y);

    
           ObjectCreate(Obj0009, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0009, D1_Wealth, 40, "Tahoma Narrow",  color_WealthD1);
   ObjectSet(Obj0009, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0009, OBJPROP_XDISTANCE, Col07x);
   ObjectSet(Obj0009, OBJPROP_YDISTANCE, Col01y);
   
    
           ObjectCreate(Obj0010, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0010, W1_Wealth, 40, "Tahoma Narrow",  color_WealthW1);
   ObjectSet(Obj0010, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0010, OBJPROP_XDISTANCE, Col08x);
   ObjectSet(Obj0010, OBJPROP_YDISTANCE, Col01y);   
   
   
           ObjectCreate(Obj0011, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0011, MN1_Wealth, 40, "Tahoma Narrow",  color_WealthMN1);
   ObjectSet(Obj0011, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0011, OBJPROP_XDISTANCE, Col09x);
   ObjectSet(Obj0011, OBJPROP_YDISTANCE, Col01y); 
   
   WindowRedraw() ;  
      
   return(0);
  }
//+------------------------------------------------------------------+

int deinit()
  {
 

deleteObject() ;

//ObjectsDeleteAll(0); 

 
   return(0);
  }

//+------------------------------------------------------------------+
  
void deleteObject()
  { 
//ObjectDelete(Obj0001);  
ObjectDelete(Obj0002); 
ObjectDelete(Obj0003); 
ObjectDelete(Obj0004); 
ObjectDelete(Obj0005); 
ObjectDelete(Obj0006); 
ObjectDelete(Obj0007); 
ObjectDelete(Obj0008); 
ObjectDelete(Obj0009); 
ObjectDelete(Obj0010); 
ObjectDelete(Obj0011); 

ObjectDelete(ObjHead01);  
ObjectDelete(ObjHead02); 
ObjectDelete(ObjHead03); 
ObjectDelete(ObjHead04); 
ObjectDelete(ObjHead05); 
ObjectDelete(ObjHead06); 
ObjectDelete(ObjHead07); 
ObjectDelete(ObjHead08); 
ObjectDelete(ObjHead09); 

 
  }

//+------------------------------------------------------------------+
 
string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN";
   }
   return(tfs);
}

//+------------------------------------------------------------------+
 
/*

The system only uses two indicators the ADX and the Zerolag Tema 2. 
Please see the attached chart. 
Default settings used for both indies. 
For the ADX I only use the +DI and -DI lines.

Rules for entering a buy: 

Price must currently be under the Zerolag and ADX -DI must be above the +DI. 
When the +DI crosses the -DI and is above the -DI we wait for the price itself to open above the Zerolag. 
As soon as price opens above Zerolag a BUY must be opened. 
EA must have TP, SL, Lot size etc. 

If trade goes against us and price opens below the Zerolag the buy order must be closed and a sell order opened. 
Look at how many pips were lost and the sell order TP must then be the number of pips lost plus 2pips. 
In other words if we lost 6 pips then the TP on the sell order will be 8pips. 

If possible a static SL can be built in to protect profit. 
Lets say Static SL is set to 3pips. 
If price goes 6pips in our favor and price turns against us EA must close order at 3pips profit.

For a sell order the opposite of above. 

*/