QQE_arr.mq4

QQE_arr.mq4 download link will appear after 10 seconds.




QQE_arr.mq4 Programming source code

//#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1  clrLime
#property indicator_color2  clrRed
#property indicator_color3  clrNONE
#property indicator_color4  clrNONE

extern double SF                  = 1.0;
extern int    RSIPeriod           = 7;
extern double WP                  = 3.5;
extern int    dist                = 36;
extern bool   Show_Signal_Cross   = true;
extern bool   Show_Fifty_Cross    = false;
extern bool   alertsOn            = true;
extern bool   alertsOnCurrent     = true;
extern bool   alertsOnSignalCross = true;
extern bool   alertsOnLevelCross  = false;
extern bool   alertsMessage       = true;
extern bool   alertsSound         = true;
extern bool   alertsNotify        = false;
extern bool   alertsEmail         = false;
extern int    AlertLevel          = 50;
extern int    arrowSize           = 2;

double Trend[];
double RsiMa[];
double CrossUp[];
double CrossDn[];
double FiftyUp[];
double FiftyDn[];
double trend1[];
double trend2[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int init()
{
   IndicatorBuffers(8);
   SetIndexBuffer(0,CrossUp);  SetIndexStyle(0,DRAW_ARROW,0,arrowSize); SetIndexArrow(0,241);
   SetIndexBuffer(1,CrossDn);  SetIndexStyle(1,DRAW_ARROW,0,arrowSize); SetIndexArrow(1,242);
   SetIndexBuffer(2,FiftyUp);  SetIndexStyle(2,DRAW_ARROW,0,arrowSize); SetIndexArrow(2,241);
   SetIndexBuffer(3,FiftyDn);  SetIndexStyle(3,DRAW_ARROW,0,arrowSize); SetIndexArrow(3,242);
   SetIndexBuffer(4,RsiMa);    SetIndexLabel(4,"QQE");
   SetIndexBuffer(5,Trend);    SetIndexLabel(5,"QQE trend");
   SetIndexBuffer(6,trend1);
   SetIndexBuffer(7,trend2);
   if (Show_Signal_Cross)
   {
      SetIndexStyle(0,DRAW_ARROW,0,2); SetIndexArrow(0,119);
      SetIndexStyle(1,DRAW_ARROW,0,2); SetIndexArrow(1,119);
   }
   else
   {
      SetIndexStyle(0,DRAW_NONE);
      SetIndexStyle(1,DRAW_NONE);
   }
   if (Show_Fifty_Cross)
   {
      SetIndexStyle(2,DRAW_ARROW,0,1); SetIndexArrow(2,225);
      SetIndexStyle(3,DRAW_ARROW,0,1); SetIndexArrow(3,226);
   }
   else
   {
      SetIndexStyle(2,DRAW_NONE);
      SetIndexStyle(3,DRAW_NONE);
   }              
   IndicatorShortName("QQE ("+SF+","+RSIPeriod+")");
   return(0);
}

//
//
//
//
//

double emas[][3];
#define iEma 0
#define iEmm 1
#define iQqe 2

int start()
{
   int i,r,counted_bars=IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
           int limit = Bars-counted_bars;
           if (ArrayRange(emas,0) != Bars) ArrayResize(emas,Bars); 

   //
   //
   //
   //
   //

   double alpha1 = 2.0/(SF+1.0);
   double alpha2 = 2.0/(RSIPeriod*2.0);
   for (i=limit, r=Bars-i-1; i>=0; i--,r++)
   {  
      RsiMa[i]   = RsiMa[i+1] + alpha1*(iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i) - RsiMa[i+1]);
      emas[r][iEma] = emas[r-1][iEma] + alpha2*(MathAbs(RsiMa[i+1]-RsiMa[i]) - emas[r-1][iEma]);
      emas[r][iEmm] = emas[r-1][iEmm] + alpha2*(emas[r][iEma] - emas[r-1][iEmm]);

      //
      //
      //
      //
      //

         double rsi0 = RsiMa[i];
         double rsi1 = RsiMa[i+1];
         double dar  = emas[r  ][iEmm]*WP;
         double tr   = emas[r-1][iQqe];
         double dv   = tr;
   
            if (rsi0 < tr) { tr = rsi0 + dar; if ((rsi1 < dv) && (tr > dv)) tr = dv; }
            if (rsi0 > tr) { tr = rsi0 - dar; if ((rsi1 > dv) && (tr < dv)) tr = dv; }

         Trend[i]      = tr;
         emas[r][iQqe] = tr;
         
         trend1[i] = trend1[i+1];
            if(RsiMa[i]>Trend[i]) trend1[i] = 1;
            if(RsiMa[i]AlertLevel) trend2[i] = 1;
            if(RsiMa[i]