//+------------------------------------------------------------------+ 
//|   _TRO_jjrvatTrigger                                             | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 


#property  copyright "Copyright © 2008, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpledone.com/" 

//---- indicator settings 
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1



//---- indicator parameters  
 

extern int win = 0;
extern int price.x.offset= 0 ; 
extern int price.y.offset= 100 ; 

extern bool  Sound.Alert      = FALSE;
extern bool  Show.Comment     = true;
extern int   Chart_Period1    = 60;
 

extern int   myFontSize       = 75;

extern string Up_Message = "LONG" ;
extern string Eq_Message = "WAIT" ;
extern string Dn_Message = "SHORT" ;

extern color Up_color = Lime;
extern color Eq_color = Orange;
extern color Dn_color = Red;


//---- indicator buffers 



//---- buffers
  double close;
  double bid, ask;
string tMessage, tPrice, symbol, period ;


bool bTrigger  = false ;
bool bTrigger1 = true ;

//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 

symbol = Symbol() ;
period = Period() ;
   return(0); 
  } 

int deinit() 
{ 

   
   ObjectsDeleteAll(0);
  
}  

//+------------------------------------------------------------------+ 
//| Range                                                            | 
//+------------------------------------------------------------------+ 
int start() 
  { 
  
double xPrice ;  

//double xopen   = iOpen(NULL,Chart_Period1,0) ; 
//double xclose  = iClose(NULL,Chart_Period1,0) ; 


color HighColor, LowColor, MidColor, Mid1Color, CloseColor, ClOpColor;

close = Close[0];
bid = Bid ; 
ask = Ask ;


double FAST_MA  = iMA(NULL,period,5,0,1,PRICE_CLOSE,0);
double SLOW_MA  = iMA(NULL,period,240,0,3,PRICE_CLOSE,0);

double FAST_MA1  = iMA(NULL,period,5,0,1,PRICE_CLOSE,1);
double SLOW_MA1  = iMA(NULL,period,240,0,3,PRICE_CLOSE,1);


bool bFastAbove = FAST_MA > SLOW_MA ;
bool bFastLong  = FAST_MA >= FAST_MA1 ;

bool bSlowLong  = SLOW_MA >= SLOW_MA1 ;

if(Show.Comment) 
{Comment("close=", DoubleToStr(close, Digits)," ",  DoubleToStr(bid, Digits), "x", DoubleToStr(ask, Digits) ); }

if( bFastAbove && bFastLong && bSlowLong)    { bTrigger = true;  tMessage = Up_Message ; ClOpColor = Up_color ; } else {
if( !bFastAbove && !bFastLong && !bSlowLong) { bTrigger = true;  tMessage = Dn_Message ; ClOpColor = Dn_color ; } else {
                                               bTrigger = false; tMessage = Eq_Message ; ClOpColor = Eq_color ; } }  
                                             
                                   
tPrice = " " + DoubleToStr(close, Digits) ;  

if(bTrigger && bTrigger1 != bTrigger && Sound.Alert && tMessage != Eq_Message ) { Alert("jjrvat ", Symbol(), " ",tMessage + tPrice  ) ; }

bTrigger1 = bTrigger ;

//+------------------------------------------------------------------+  
 
                 
                    
   ObjectCreate("2jjr30", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("2jjr30",Symbol(), myFontSize , "Arial Bold", ClOpColor );
   ObjectSet("2jjr30", OBJPROP_CORNER, 0);
   ObjectSet("2jjr30", OBJPROP_XDISTANCE, price.x.offset); 
   ObjectSet("2jjr30", OBJPROP_YDISTANCE, price.y.offset); 
   ObjectSet("2jjr30",OBJPROP_BACK,true);       

//+------------------------------------------------------------------+  
 
tPrice = " " + DoubleToStr(close, Digits) ;               
                    
   ObjectCreate("2jjr31", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("2jjr31",tPrice, myFontSize , "Arial Bold", ClOpColor );
   ObjectSet("2jjr31", OBJPROP_CORNER, 0);
   ObjectSet("2jjr31", OBJPROP_XDISTANCE, price.x.offset); 
   ObjectSet("2jjr31", OBJPROP_YDISTANCE, 10+myFontSize+price.y.offset); 
   ObjectSet("2jjr31",OBJPROP_BACK,true); 

//+------------------------------------------------------------------+        
   ObjectCreate("2jjr32", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("2jjr32",tMessage, myFontSize , "Arial Bold", ClOpColor );
   ObjectSet("2jjr32", OBJPROP_CORNER, 0);
   ObjectSet("2jjr32", OBJPROP_XDISTANCE, price.x.offset); 
   ObjectSet("2jjr32", OBJPROP_YDISTANCE, (10+myFontSize)*2+price.y.offset); 
   ObjectSet("2jjr32",OBJPROP_BACK,true); 
   
//+------------------------------------------------------------------+      
   
   WindowRedraw();    
 
 

 
   return(0); 
} 

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

 