dex_SCALP





//+------------------------------------------------------------------+
//|                                                    dex_SCALP.mq4 |
//|                                        Copyright © 2004, akadex. |
//|                                                           tohell |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, akadex"
#property link      "tohell"
#property indicator_buffers 2
#property indicator_color1 SteelBlue
#property indicator_color2 White
#property indicator_separate_window

extern int aPeriod = 5;//EUR 5
extern int bPeriod = 15;//EUR 15
extern double K = 1.0;//EUR 1.0

double RSIBuf[],UpZone[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,RSIBuf);
   SetIndexBuffer(1,UpZone);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double MA, RSI[];
   ArrayResize(RSI,bPeriod);
   int counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   for(int i=limit; i>=0; i--)
   {
      RSIBuf[i] = iStdDev(NULL,0,aPeriod,MODE_EMA,0,PRICE_MEDIAN,i);
      MA = 0;
      for(int j=i; j<i+bPeriod; j++) {
         RSI[j-i] = RSIBuf[j];
         MA += RSIBuf[j]/bPeriod;
      }
      UpZone[i] = MA + (K * StDev(RSI,bPeriod));
   }
   
//----
   return(0);
  }
  
double StDev(double& Data[], int Per)
{
  return(MathSqrt(Variance(Data,Per)));
}

double Variance(double& Data[], int Per)
{
  double sum, ssum;
  for (int i=0; i<Per; i++)
  {
    sum += Data[i];
    ssum += MathPow(Data[i],2);
  }
  return((ssum*Per - sum*sum)/(Per*(Per-1)));
}
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM
Implements a curve of type DRAW_LINE


Indicators Used:

Standard Deviation indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: