//+------------------------------------------------------------------+
//|                                      Forex Rebellion EA Lite.mq4 |
//|                                       Copyright © 2009, Russ Horn|
//|                                     http://www.forexrebellion.com|
//+------------------------------------------------------------------+

#property copyright "Copyright © 2009 Russ Horn"
#property link      "http://www.forexrebellion.com"

extern int x_distance = 5;
extern int y_distance = 15;
extern int corner = 1;
extern color base_color = Black;
extern bool   PopUpAlert=true;
extern bool   SoundAlert=true;

double alertTag;
int trend = 0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   ObjectDelete("title0"); ObjectDelete("title1"); ObjectDelete("title2");ObjectDelete("title3");ObjectDelete("title4");
   ObjectDelete("entry1"); ObjectDelete("entry2");ObjectDelete("entry3");ObjectDelete("entry4");
   ObjectDelete("entryrule1"); ObjectDelete("entryrule2");ObjectDelete("entryrule3");ObjectDelete("entryrule4");
   ObjectDelete("entryresult1"); ObjectDelete("entryresult2");ObjectDelete("entryresult3");ObjectDelete("entryresult4");
   ObjectDelete("entrysummary1"); ObjectDelete("entrysummary2");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("title0"); ObjectDelete("title1"); ObjectDelete("title2");ObjectDelete("title3");ObjectDelete("title4");
   ObjectDelete("entry1"); ObjectDelete("entry2");ObjectDelete("entry3");ObjectDelete("entry4");
   ObjectDelete("entryrule1"); ObjectDelete("entryrule2");ObjectDelete("entryrule3");ObjectDelete("entryrule4");
   ObjectDelete("entryresult1"); ObjectDelete("entryresult2");ObjectDelete("entryresult3");ObjectDelete("entryresult4");
   ObjectDelete("entrysummary1"); ObjectDelete("entrysummary2");   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

   int trend_1 , trend_2 , trend_3 , trend_4;

ObjectCreate("title0", OBJ_LABEL, 0, 0, 0);
ObjectSetText("title0","§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§",9, "Wingdings", base_color);
ObjectSet("title0", OBJPROP_CORNER, corner);
ObjectSet("title0", OBJPROP_XDISTANCE, x_distance);
ObjectSet("title0", OBJPROP_YDISTANCE, y_distance);

ObjectCreate("title1", OBJ_LABEL, 0, 0, 0);
ObjectSetText("title1"," FOREX REBELLION T.A.",9, "Arial Black", base_color);
ObjectSet("title1", OBJPROP_CORNER, corner);
ObjectSet("title1", OBJPROP_XDISTANCE, x_distance);
ObjectSet("title1", OBJPROP_YDISTANCE, y_distance+8);

ObjectCreate("title2", OBJ_LABEL, 0, 0, 0);
ObjectSetText("title2","§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§",9, "Wingdings", base_color);
ObjectSet("title2", OBJPROP_CORNER, corner);
ObjectSet("title2", OBJPROP_XDISTANCE, x_distance);
ObjectSet("title2", OBJPROP_YDISTANCE, y_distance+22);

   string tradeAssistant = "";
   
   double CandleClose = Close[1];
   double ShiftedEma5 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 6);
   double Ema4 = iMA(NULL, 0, 4, 0, MODE_EMA, PRICE_CLOSE, 1);
   double Ema5 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 1);
   double QQE_RSI = iCustom(NULL, 0, "QQE ADV", 0, 1);
   double QQE_WP = iCustom(NULL, 0, "QQE ADV", 1, 1);

   ObjectCreate("entry1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entry1"," ENTRY RULE 1:",9, "Arial Black", base_color);
   ObjectSet("entry1", OBJPROP_CORNER, corner);
   ObjectSet("entry1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entry1", OBJPROP_YDISTANCE, y_distance+35);
   
   if (CandleClose < ShiftedEma5)   
   {

   ObjectCreate("entryresult1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult1"," the price trend is BEARISH",9, "Arial Black", Red);
   ObjectSet("entryresult1", OBJPROP_CORNER, corner);
   ObjectSet("entryresult1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult1", OBJPROP_YDISTANCE, y_distance+50);

   trend_1 = -1;
   } else {

   ObjectCreate("entryresult1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult1"," the price trend is BULLISH",9, "Arial Black", Blue);
   ObjectSet("entryresult1", OBJPROP_CORNER, corner);
   ObjectSet("entryresult1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult1", OBJPROP_YDISTANCE, y_distance+50);

   trend_1 = 1;
   }


   ObjectCreate("entry2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entry2"," ENTRY RULE 2:",9, "Arial Black", base_color);
   ObjectSet("entry2", OBJPROP_CORNER, corner);
   ObjectSet("entry2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entry2", OBJPROP_YDISTANCE, y_distance+70);


   if (Ema4 < Ema5)
   {

   ObjectCreate("entryresult2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult2"," EMAs cross is BEARISH",9, "Arial Black", Red);
   ObjectSet("entryresult2", OBJPROP_CORNER, corner);
   ObjectSet("entryresult2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult2", OBJPROP_YDISTANCE, y_distance+85);

   trend_2 = -1;
   } else {

   ObjectCreate("entryresult2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult2"," EMAs cross is BULLISH",9, "Arial Black", Blue);
   ObjectSet("entryresult2", OBJPROP_CORNER, corner);
   ObjectSet("entryresult2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult2", OBJPROP_YDISTANCE, y_distance+85);

   trend_2 = 1;
   }

   ObjectCreate("entry3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entry3"," ENTRY RULE 3:",9, "Arial Black", base_color);
   ObjectSet("entry3", OBJPROP_CORNER, corner);
   ObjectSet("entry3", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entry3", OBJPROP_YDISTANCE, y_distance+105);

   if (QQE_RSI < QQE_WP )
   {

   ObjectCreate("entryresult3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult3"," QQE cross is BEARISH",9, "Arial Black", Red);
   ObjectSet("entryresult3", OBJPROP_CORNER, corner);
   ObjectSet("entryresult3", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult3", OBJPROP_YDISTANCE, y_distance+120);

   trend_3 = -1;
   } else {

   ObjectCreate("entryresult3", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult3"," QQE cross is BULLISH",9, "Arial Black", Blue);
   ObjectSet("entryresult3", OBJPROP_CORNER, corner);
   ObjectSet("entryresult3", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult3", OBJPROP_YDISTANCE, y_distance+120);

   trend_3 = 1;
   }

   ObjectCreate("entry4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entry4"," ENTRY RULE 4:",9, "Arial Black", base_color);
   ObjectSet("entry4", OBJPROP_CORNER, corner);
   ObjectSet("entry4", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entry4", OBJPROP_YDISTANCE, y_distance+140);
    
   if (QQE_RSI < 50)
   {
   ObjectCreate("entryresult4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult4"," QQE is BEARISH",9, "Arial Black", Red);
   ObjectSet("entryresult4", OBJPROP_CORNER, corner);
   ObjectSet("entryresult4", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult4", OBJPROP_YDISTANCE, y_distance+155);

   trend_4 = -1;
   } else {
   
   ObjectCreate("entryresult4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entryresult4"," QQE is BULLISH",9, "Arial Black", Blue);
   ObjectSet("entryresult4", OBJPROP_CORNER, corner);
   ObjectSet("entryresult4", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entryresult4", OBJPROP_YDISTANCE, y_distance+155);

   trend_4 = 1;
   }

ObjectCreate("title3", OBJ_LABEL, 0, 0, 0);
ObjectSetText("title3","§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§",9, "Wingdings", base_color);
ObjectSet("title3", OBJPROP_CORNER, corner);
ObjectSet("title3", OBJPROP_XDISTANCE, x_distance);
ObjectSet("title3", OBJPROP_YDISTANCE, y_distance+175);


   int trend_score = trend_1 + trend_2 + trend_3 + trend_4;
   
   if (trend_score == 4)
   {
   ObjectCreate("entrysummary1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary1"," LONG ENTRY rules are all in line.",9, "Arial Black", Blue);
   ObjectSet("entrysummary1", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary1", OBJPROP_YDISTANCE, y_distance+190);

   ObjectCreate("entrysummary2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary2"," Consider entering a LONG TRADE.",9, "Arial Black", Blue);
   ObjectSet("entrysummary2", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary2", OBJPROP_YDISTANCE, y_distance+205);
   
   if (trend!=1 && PopUpAlert && alertTag!=Time[0])
   {
      Alert("FOREX REBELLION: based on entry rules, " + Symbol() + " " + Period() +" is good for a LONG trade!");
      alertTag = Time[0];
   }

   if (trend!=1 && SoundAlert && alertTag!=Time[0])
   {
      PlaySound("alert.wav");
      alertTag = Time[0];
   }

   trend = 1;
      
   }

   if (trend_score == -4)
   {
   ObjectCreate("entrysummary1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary1"," SHORT ENTRY rules are all in line.",9, "Arial Black", Red);
   ObjectSet("entrysummary1", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary1", OBJPROP_YDISTANCE, y_distance+190);

   ObjectCreate("entrysummary2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary2"," Consider entering a SHORT TRADE.",10, "Arial Black", Red);
   ObjectSet("entrysummary2", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary2", OBJPROP_YDISTANCE, y_distance+205);

   if (trend != -1 && PopUpAlert && alertTag!=Time[0])
   {
      Alert("FOREX REBELLION: based on entry rules, " + Symbol() + " " + Period() +" is good for a SHORT trade!");
      alertTag = Time[0];
   }

   if (trend != -1 && SoundAlert && alertTag!=Time[0])
   {
      PlaySound("alert.wav");
      alertTag = Time[0];
   }
   
   trend = -1;
   
   }

   if (trend_score > -4 && trend_score < 4)
   {
   ObjectCreate("entrysummary1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary1"," No entry for now.",10, "Arial", base_color);
   ObjectSet("entrysummary1", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary1", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary1", OBJPROP_YDISTANCE, y_distance+190);

   ObjectCreate("entrysummary2", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("entrysummary2"," Wait for all the rules to be in line.",9, "Arial", base_color);
   ObjectSet("entrysummary2", OBJPROP_CORNER, corner);
   ObjectSet("entrysummary2", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("entrysummary2", OBJPROP_YDISTANCE, y_distance+205);
   }
   

   ObjectCreate("title4", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("title4","§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§",9, "Wingdings", base_color);
   ObjectSet("title4", OBJPROP_CORNER, corner);
   ObjectSet("title4", OBJPROP_XDISTANCE, x_distance);
   ObjectSet("title4", OBJPROP_YDISTANCE, y_distance+225);

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