//+------------------------------------------------------------------+
//|                                              QQE-Stoch Combi.mq4 |
//|                      Copyright © 2012, Shahrooz Sadeghi          |
//|                           http://www.forexfactory.com/shahrooz67 |
//+------------------------------------------------------------------+
#property copyright "Shahrooz Sadeghi © 2012"
#property link      "http://www.forexfactory/shahrooz67"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_minimum -20.0
#property indicator_maximum 20.0
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 LightGreen
#property indicator_color5 OrangeRed
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2


extern int KPeriod_Stoch=13;
extern int DPeriod_Stoch=3;
extern int Slowing_Stoch=3;
extern int SF_QQE=5;
extern int bars=3000;
extern string MAIL="sh_sadeghi_me@yahoo.com";

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   IndicatorShortName("");
   IndicatorBuffers(5);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 159);
   SetIndexLabel(0, "Strong Bullish ");
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 159);
   SetIndexLabel(1, "Strong Bearish ");
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 159);
   SetIndexLabel(2, "Neutral ");
      SetIndexBuffer(3, ExtMapBuffer4);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 159);
   SetIndexLabel(3, "Weak Bulish ");
      SetIndexBuffer(4, ExtMapBuffer5);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 159);
   SetIndexLabel(4, "Weak Bearish ");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
double QQE_main;
double QQE_signal;
double Stoch_main,Stoch_signal;
double QQE_main_last;
double QQE_signal_last;
double Stoch_main_last,Stoch_signal_last;
int limit;
if (bars>Bars) limit=Bars;
else limit= bars;

int   counted_bars=IndicatorCounted();

for (int i=0;i<limit;i++)
{
   QQE_main=iCustom(Symbol(),0,"QQE",SF_QQE,0,i);
    QQE_signal=iCustom(Symbol(),0,"QQE",SF_QQE,1,i);
    QQE_main_last=iCustom(Symbol(),0,"QQE",SF_QQE,0,i+1);
    QQE_signal_last=iCustom(Symbol(),0,"QQE",SF_QQE,1,i+1);
    Stoch_main=iCustom(Symbol(),0,"QQE-stoch",KPeriod_Stoch,DPeriod_Stoch,Slowing_Stoch,0,i);
    Stoch_signal=iCustom(Symbol(),0,"QQE-stoch",KPeriod_Stoch,DPeriod_Stoch,Slowing_Stoch,1,i);
      Stoch_main_last=iCustom(Symbol(),0,"QQE-stoch",SF_QQE,0,i+1);
    Stoch_signal_last=iCustom(Symbol(),0,"QQE-stoch",SF_QQE,1,i+1);
    if( Stoch_main > Stoch_signal && QQE_main>QQE_signal && QQE_main>=50)
    //&& 
   // Stoch_main >QQE_main)
    {
     ExtMapBuffer1[i]=15;
  ExtMapBuffer2[i]=EMPTY_VALUE;
  ExtMapBuffer3[i]=EMPTY_VALUE;
   ExtMapBuffer4[i]=EMPTY_VALUE;
  ExtMapBuffer5[i]=EMPTY_VALUE;
   }
   else     if( Stoch_main > Stoch_signal && QQE_main>QQE_signal)
   // && 
  // Stoch_main <QQE_main)
    {
       ExtMapBuffer1[i]=EMPTY_VALUE;
  ExtMapBuffer2[i]=EMPTY_VALUE;
  ExtMapBuffer3[i]=EMPTY_VALUE;
   ExtMapBuffer4[i]=7.5;
  ExtMapBuffer5[i]=EMPTY_VALUE;
   }
   else if ( Stoch_main < Stoch_signal && QQE_main<QQE_signal && QQE_main<=50)
    //&& 
   // Stoch_main >QQE_main)
    {
     ExtMapBuffer1[i]=EMPTY_VALUE;
  ExtMapBuffer2[i]=-15;
  ExtMapBuffer3[i]=EMPTY_VALUE;
   ExtMapBuffer4[i]=EMPTY_VALUE;
  ExtMapBuffer5[i]=EMPTY_VALUE;
   }
   else if ( Stoch_main < Stoch_signal && QQE_main<QQE_signal )
    //&& 
   // Stoch_main >QQE_main)
    {
     ExtMapBuffer1[i]=EMPTY_VALUE;
  ExtMapBuffer2[i]=EMPTY_VALUE;
  ExtMapBuffer3[i]=EMPTY_VALUE;
   ExtMapBuffer4[i]=EMPTY_VALUE;
  ExtMapBuffer5[i]=-7.5;
   }
else
{
     ExtMapBuffer1[i]=EMPTY_VALUE;
  ExtMapBuffer2[i]=EMPTY_VALUE;
  ExtMapBuffer3[i]=0;
   ExtMapBuffer4[i]=EMPTY_VALUE;
  ExtMapBuffer5[i]=EMPTY_VALUE;
   }
   }
   
   Comment ( " Spread = " , MarketInfo(Symbol(),MODE_SPREAD));
//----
   return(0);
  }
//+------------------------------------------------------------------+