//+------------------------------------------------------------------+
//|                                                  multimintv3.mq4 |
//|                                                       IT-Guy Mod |
//+------------------------------------------------------------------+
#property copyright "IT-Guy"
#property indicator_chart_window

#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
//---- input parameters
extern string Lbl = "Choose color of text";
extern color lblcolor= White;
extern string Loc = "Choose corner placement";
extern string Loc2 = "0-TopLeft, 1-TopRight";
extern string Loc3 = "2-BottomLeft, 3-BottomRight";
extern int location = 1;
extern int UpperTimeframe = 1440;
extern int LowerTimeframe = 60;
extern bool DoPopupAlerts = false;
extern bool DoEmailAlerts = false;
extern string ind1 = "Hourly Dinapoli Stoch";
extern int k_h = 8;
extern int sl_h = 3;
extern int d_h = 3;
extern string ind2 = "Daily Dinapoli Stoch";
extern int k_d = 8;
extern int sl_d = 3;
extern int d_d = 3;
extern string ind3 = "RSI";
extern int rsih = 13;
extern int rsid = 13;
extern string ind4 = "Hourly and Daily Moving Averages";
extern int ma1h = 5;
extern int ma2h = 8;
extern int ma1d = 5;
extern int ma2d = 8;
bool TickCheck = False;
bool EachTickMode = false;
//---- internal global 
int bar = 0;
int bard = 0;
int BarCount;
int Current;
string daily_direction;
string hour_direction;
int BarsCount = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
 {
   BarCount = Bars;

   if (EachTickMode) Current = 0; else Current = 1;

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("symbAUDJPY");
   ObjectDelete("symbGBPUSD");
   ObjectDelete("symbEURJPY");
   ObjectDelete("symbGBPJPY");
   ObjectDelete("symbEURCAD");
   ObjectDelete("symbGBPCHF");

   Comment(" ");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Trend                                                         |
//+------------------------------------------------------------------+
int start() {
if (Bars > BarsCount){
daily_direction=" ";
int yd=0;
string longl="LONG";
string shortl="SHORT";
string ntl="NO TRADE";
hour_direction=" ";
string sym[6]={"EURJPY","GBPUSD","GBPJPY","AUDJPY","EURCAD","GBPCHF"};
int s;
for(s=0; s<6; s++){
double bma1d = iMA(sym[s], UpperTimeframe, ma1d, 0, 1, 0, 1);
double bma2d = iMA(sym[s], UpperTimeframe, ma2d, 0, 1, 1, 1);
double sma1d = iMA(sym[s], UpperTimeframe, ma1d, 0, 1, 0, 1);
double sma2d = iMA(sym[s], UpperTimeframe, ma2d, 0, 1, 1, 1);
double bma1h = iMA(sym[s], LowerTimeframe, ma1h, 0, 1, 0, 1);
double bma2h = iMA(sym[s], LowerTimeframe, ma2h, 0, 1, 1, 1);
double sma1h = iMA(sym[s], LowerTimeframe, ma1h, 0, 1, 0, 1);
double sma2h = iMA(sym[s], LowerTimeframe, ma2h, 0, 1, 1, 1);


double bst1h = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", k_h, sl_h, d_h, 0, 1);
double bst2h = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", k_h, sl_h, d_h, 1, 1);
double bst1d = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", k_d, sl_d, d_d, 0, 1);
double bst2d = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", k_d, sl_d, d_d, 1, 1);

double sst1h = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", k_h, sl_h, d_h, 0, 1);
double sst2h = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", k_h, sl_h, d_h, 1, 1);
double sst1d = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", k_d, sl_d, d_d, 0, 1);
double sst2d = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", k_d, sl_d, d_d, 1, 1);

double bst1h2 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double bst2h2 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);
double bst1d2 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double bst2d2 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);

double sst1h2 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double sst2h2 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);
double sst1d2 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double sst2d2 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);

double bst1h21 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double bst2h21 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);
double bst1d21 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double bst2d21 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);

double sst1h21 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double sst2h21 = iCustom(sym[s], LowerTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);
double sst1d21 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 0, 1);
double sst2d21 = iCustom(sym[s], UpperTimeframe, "StochasticDiNapoli_v1", 8, 3, 3, 1, 1);

double brsid = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double brsild = 50;
double brsih = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double brsilh = 50;
double srsid = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double srsild = 50;
double srsih = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double srsilh = 50;

double brsid2 = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double brsild2 = 50;
double brsih2 = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double brsilh2 = 50;
double srsid2 = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double srsild2 = 50;
double srsih2 = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double srsilh2 = 50;

double brsid21 = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double brsild21 = 50;
double brsih21 = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double brsilh21 = 50;
double srsid21 = iRSI(sym[s], UpperTimeframe, rsid, 0, 1);
double srsild21 = 50;
double srsih21 = iRSI(sym[s], LowerTimeframe, rsih, 0, 1);
double srsilh21 = 50;
   
if (bma1d > bma2d&&brsid > brsild&&bst1d > bst2d){
   daily_direction =longl;
   
     {

     }
   }
   if (bma1d < bma2d&&brsid > brsild&&bst1d > bst2d){
   daily_direction =ntl;
   
     {

     }
   }
      if (bma1d > bma2d&&brsid < brsild&&bst1d > bst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (bma1d > bma2d&&brsid > brsild&&bst1d < bst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (bma1d < bma2d&&brsid < brsild&&bst1d > bst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (bma1d < bma2d&&brsid > brsild&&bst1d < bst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (bma1d > bma2d&&brsid < brsild&&bst1d < bst2d){
   daily_direction =ntl;
   
     {

     }
   }
   if (sma1d < sma2d&&srsid < srsild&&sst1d < sst2d){
   daily_direction =shortl;
   
     {

     }
   }
      if (sma1d > sma2d&&srsid < srsild&&sst1d < sst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (sma1d < sma2d&&srsid > srsild&&sst1d < sst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (sma1d < sma2d&&srsid < srsild&&sst1d > sst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (sma1d > sma2d&&srsid > srsild&&sst1d < sst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (sma1d < sma2d&&srsid > srsild&&sst1d > sst2d){
   daily_direction =ntl;
   
     {

     }
   }
         if (sma1d > sma2d&&srsid < srsild&&sst1d > sst2d){
   daily_direction =ntl;
   
     {

     }
   }
   
   if (bma1h > bma2h&&brsih > brsilh&&bst1h > bst2h){
   hour_direction =longl;
  
     {

     }
   }
      if (bma1h < bma2h&&brsih > brsilh&&bst1h > bst2h){
   hour_direction =ntl;
  
     {

     }
   }
         if (bma1h > bma2h&&brsih < brsilh&&bst1h > bst2h){
   hour_direction =ntl;
  
     {

     }
   }
         if (bma1h > bma2h&&brsih > brsilh&&bst1h < bst2h){
   hour_direction =ntl;
  
     {

     }
   }
         if (bma1h < bma2h&&brsih < brsilh&&bst1h > bst2h){
   hour_direction =ntl;
  
     {

     }
   }
         if (bma1h > bma2h&&brsih < brsilh&&bst1h < bst2h){
   hour_direction =ntl;
  
     {

     }
   }
         if (bma1h < bma2h&&brsih > brsilh&&bst1h < bst2h){
   hour_direction =ntl;
  
     {

     }
   }
   if (sma1h < sma2h&&srsih < srsilh&&sst1h < sst2h){
   hour_direction =shortl;
   
     {

     }
   }
      if (sma1h > sma2h&&srsih < srsilh&&sst1h < sst2h){
   hour_direction =ntl;
   
     {

     }
   }
         if (sma1h < sma2h&&srsih > srsilh&&sst1h < sst2h){
   hour_direction =ntl;
   
     {

     }
   }
         if (sma1h < sma2h&&srsih < srsilh&&sst1h > sst2h){
   hour_direction =ntl;
   
     {

     }
   }
         if (sma1h > sma2h&&srsih > srsilh&&sst1h < sst2h){
   hour_direction =ntl;
   
     {

     }
   }
         if (sma1h < sma2h&&srsih > srsilh&&sst1h > sst2h){
   hour_direction =ntl;
   
     {

     }
   }
         if (sma1h > sma2h&&srsih < srsilh&&sst1h > sst2h){
   hour_direction =ntl;
   
     {

     }
   }
   yd=yd+20;

if ((daily_direction==longl && hour_direction == shortl)||
    (daily_direction==shortl && hour_direction == longl)||
    (daily_direction==ntl && hour_direction == shortl)||
    (daily_direction==shortl && hour_direction == ntl)||
    (daily_direction==longl && hour_direction == ntl)||
    (daily_direction==ntl && hour_direction == longl))
      DrawYellowObjects(sym[s],daily_direction,hour_direction,yd);   
if (daily_direction==longl && hour_direction == longl)DrawGreenObjects(sym[s],daily_direction,hour_direction,
                                                                        yd,bma1d,bma2d,bst1d,bst2d,brsid,bma1h,bma2h,bst1h,bst2h,brsih);
if (daily_direction==shortl && hour_direction == shortl)DrawRedObjects(sym[s],daily_direction,hour_direction,
                                                                        yd,bma1d,bma2d,bst1d,bst2d,brsid,bma1h,bma2h,bst1h,bst2h,brsih);
if (daily_direction==ntl &&  hour_direction==ntl)DrawObjects(sym[s],daily_direction,hour_direction,yd);

BarsCount=Bars;

}
}
   return(0);
  }
//+------------------------------------------------------------------+

void DrawObjects(string symb, string daily_direction, string hour_direction,int yd){
string trdlbl="symb"+symb;
ObjectCreate(trdlbl,OBJ_LABEL,0,0,0,0);
ObjectSet(trdlbl,OBJPROP_CORNER,location);
ObjectSet(trdlbl,OBJPROP_YDISTANCE,yd);
ObjectSet(trdlbl,OBJPROP_XDISTANCE,10);
string objdesc= StringConcatenate(symb," daily = ",daily_direction," hourly = ",hour_direction);
ObjectSetText(trdlbl,objdesc,10,"Times New Roman",lblcolor);

yd=yd+20;
}
void DrawGreenObjects(string symb, string daily_direction, string hour_direction,int yd, double ma1, double ma2, double stoch1,
                      double stoch2, double rsi, double ma1_h, double ma2_h, double stoch1_h, double stoch2_h, double rsi_h){
string trdlbl="symb"+symb;
string emailsubj=("Buy Triggered on "+symb);
string emailbody= (" A Buy has triggered on "+symb+
                     "\n"+"Time : "+TimeToStr(TimeCurrent(),TIME_MINUTES)+
                     "\n"+"Date : "+TimeToStr(TimeCurrent(),TIME_DATE)+
                     "\n"+"\n"+"DAILY INDICATOR VALUES"+
                     "\n"+"RSI Value: "+rsi+ 
                     "\n"+"Stochastic Value: "+stoch1+
                     "\n"+"Stochastic Signal Value: "+stoch2+
                     "\n"+"Faster Moving Average Value:"+ma1+
                     "\n"+"Slower Moving Average Value:"+ma2+
                     "\n"+"\n"+"\n"+"HOURLY INDICATOR VALUES"+
                     "\n"+"RSI Value: "+rsi_h+ 
                     "\n"+"Stochastic Value: "+stoch1_h+
                     "\n"+"Stochastic Signal Value: "+stoch2_h+
                     "\n"+"Faster Moving Average Value:"+ma1_h+
                     "\n"+"Slower Moving Average Value:"+ma2_h+
                     "\n"+"\n"+"\n"+"Sincerly, "+
                     "\n"+"Your Friendly Trading Terminal");
if (DoPopupAlerts)Alert("Buy Trigger on ",symb," at ",TimeToStr(TimeCurrent()));
if (DoEmailAlerts)SendMail(emailsubj,emailbody);

                   
ObjectCreate(trdlbl,OBJ_LABEL,0,0,0,0);
ObjectSet(trdlbl,OBJPROP_CORNER,location);
ObjectSet(trdlbl,OBJPROP_YDISTANCE,yd);
ObjectSet(trdlbl,OBJPROP_XDISTANCE,10);
string objdesc= StringConcatenate(symb," daily = ",daily_direction," hourly = ",hour_direction);
ObjectSetText(trdlbl,objdesc,10,"Times New Roman",Lime);

yd=yd+20;
}
void DrawRedObjects(string symb, string daily_direction, string hour_direction,int yd, double ma1, double ma2, double stoch1,
                      double stoch2, double rsi, double ma1_h, double ma2_h, double stoch1_h, double stoch2_h, double rsi_h){
string trdlbl="symb"+symb;
string emailsubjs=("Sell Triggered on "+symb);
string emailbodys= (" A Sell has triggered on "+symb+
                     "\n"+"Time : "+TimeToStr(TimeCurrent(),TIME_MINUTES)+
                     "\n"+"Date : "+TimeToStr(TimeCurrent(),TIME_DATE)+
                     "\n"+"\n"+"DAILY INDICATOR VALUES"+
                     "\n"+"RSI Value: "+rsi+ 
                     "\n"+"Stochastic Value: "+stoch1+
                     "\n"+"Stochastic Signal Value: "+stoch2+
                     "\n"+"Faster Moving Average Value:"+ma1+
                     "\n"+"Slower Moving Average Value:"+ma2+
                     "\n"+"\n"+"\n"+"HOURLY INDICATOR VALUES"+
                     "\n"+"RSI Value: "+rsi_h+ 
                     "\n"+"Stochastic Value: "+stoch1_h+
                     "\n"+"Stochastic Signal Value: "+stoch2_h+
                     "\n"+"Faster Moving Average Value:"+ma1_h+
                     "\n"+"Slower Moving Average Value:"+ma2_h+
                     "\n"+"\n"+"\n"+"Sincerly, "+
                     "\n"+"Your Friendly Trading Terminal");
if (DoPopupAlerts)Alert("Sell Trigger on ",symb," at ",TimeToStr(TimeCurrent()) );
if (DoEmailAlerts)SendMail(emailsubjs,emailbodys); 
                   
ObjectCreate(trdlbl,OBJ_LABEL,0,0,0,0);
ObjectSet(trdlbl,OBJPROP_CORNER,location);
ObjectSet(trdlbl,OBJPROP_YDISTANCE,yd);
ObjectSet(trdlbl,OBJPROP_XDISTANCE,10);
string objdesc= StringConcatenate(symb," daily = ",daily_direction," hourly = ",hour_direction);
ObjectSetText(trdlbl,objdesc,10,"Times New Roman",Red);


yd=yd+20;
}
void DrawYellowObjects(string symb, string daily_direction, string hour_direction,int yd){
string trdlbl="symb"+symb;
ObjectCreate(trdlbl,OBJ_LABEL,0,0,0,0);
ObjectSet(trdlbl,OBJPROP_CORNER,location);
ObjectSet(trdlbl,OBJPROP_YDISTANCE,yd);
ObjectSet(trdlbl,OBJPROP_XDISTANCE,10);
string objdesc= StringConcatenate(symb," daily = ",daily_direction," hourly = ",hour_direction);
ObjectSetText(trdlbl,objdesc,10,"Times New Roman",Yellow);

yd=yd+20;
}

