Re: RSI Indicators for MT4

2451
kvak wrote: Thu Jun 01, 2023 7:42 am IBS RSI CCI with E-Averages
Requested file, added averages pack...
Man this is a damn good scalping indicator and without a doubt way better than the CCI on it's own. Thank you from the bottom of my heart for adding E-Averages to this indicator 😮

Master Kvak is it possible to upgrade this one further? Just two additional extras?

  1. Outer bands like Mrtools's version (here is Mrtools's indicator with source code)
  2. User friendly AHTF MTF dropdown

Man if this can be done it would be one of the most capable and complete indicators for trading - especially scalping

Only if you have time and sorry to bother you! 🙏

(Below is the source code too: I hope it can help)

Code: Select all

//+----------------------------------------------------------------------------------------------------------------------------------+
//|Three methods of calculating IBS, RSI, CCI are all equal in the control, everyone has a revolution of the calculation,            |
//|coefficient of relativity and aplied price (for IBS, this is not a significant parameter, but stands for symmetry of parameters). |
//|Drawing lines goes like the average of three IBS, RSI, CCI.                                                                       |
//|Inside both the direct and the inverted one can in turn turn over one of the methods,                                             |
//|they are independent of both the coup and the relativity.                                                                         |
//|You can also move lines through Shift (Shift cannot be negative).                                                                 |
//|"option_1" controls the calculation options 1 or 2. The default is 2 -> "option_1 = false".                                       |
//|"positive" controls the mirror image. The default is normal display -> "positive = true".                                         |
//+----------------------------------------------------------------------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                               IBS_RSI_CCI_v4.mq4 |
//|                                                       Martingeil |
//+------------------------------------------------------------------+
#property copyright "Martingeil"
#property link      "fx.09@mail.ru"
 
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1  clrPaleVioletRed            // buffer 0 - signal line
#property indicator_color2  clrSkyBlue    // buffer 1 - VKWB filter
#property indicator_color3  clrRed            // buffer 2 - upper channel
#property indicator_color4  clrBlue            // buffer 3 - lower channel
#property indicator_width1  2
#property indicator_width2  2
#property indicator_level1  0.0

//
//
//
//
//

enum enPrices
{
   pr_close,      // Close
   pr_open,       // Open
   pr_high,       // High
   pr_low,        // Low
   pr_median,     // Median
   pr_typical,    // Typical
   pr_weighted,   // Weighted
   pr_average,    // Average (high+low+open+close)/4
   pr_medianb,    // Average median body (open+close)/2
   pr_tbiased,    // Trend biased price
   pr_tbiased2,   // Trend biased (extreme) price
   pr_haclose,    // Heiken ashi close
   pr_haopen ,    // Heiken ashi open
   pr_hahigh,     // Heiken ashi high
   pr_halow,      // Heiken ashi low
   pr_hamedian,   // Heiken ashi median
   pr_hatypical,  // Heiken ashi typical
   pr_haweighted, // Heiken ashi weighted
   pr_haaverage,  // Heiken ashi average
   pr_hamedianb,  // Heiken ashi median body
   pr_hatbiased,  // Heiken ashi trend biased price
   pr_hatbiased2, // Heiken ashi trend biased (extreme) price
   pr_habclose,   // Heiken ashi (better formula) close
   pr_habopen ,   // Heiken ashi (better formula) open
   pr_habhigh,    // Heiken ashi (better formula) high
   pr_hablow,     // Heiken ashi (better formula) low
   pr_habmedian,  // Heiken ashi (better formula) median
   pr_habtypical, // Heiken ashi (better formula) typical
   pr_habweighted,// Heiken ashi (better formula) weighted
   pr_habaverage, // Heiken ashi (better formula) average
   pr_habmedianb, // Heiken ashi (better formula) median body
   pr_habtbiased, // Heiken ashi (better formula) trend biased price
   pr_habtbiased2 // Heiken ashi (better formula) trend biased (extreme) price
};
enum enMaTypes
{
   ma_sma,     // Simple moving average
   ma_ema,     // Exponential moving average
   ma_smma,    // Smoothed MA
   ma_lwma,    // Linear weighted MA
   ma_slwma,   // Smoothed LWMA
   ma_dsema,   // Double Smoothed Exponential average
   ma_tema,    // Triple exponential moving average - TEMA
   ma_lsma,    // Linear regression value (lsma)
   ma_nlma     // Non Lag moving average - NLMA
};


//---- midline parameters -------------------------------
extern ENUM_TIMEFRAMES TimeFrame     = PERIOD_CURRENT;
extern int      per_IBS       = 5;                // period IBS
input enMaTypes mode_IBSMa    = ma_sma;             // IBS Moving average method  
extern int      per_RSI       = 14;                // period RSI 
input enPrices  app_price_RSI = pr_close;           // Rsi price to use 
extern int      per_CCI       = 14;                // period CCI
input enPrices  app_price_CCI = pr_typical;         // Cci price to use 
extern int      porog         = 50;                // threshold

//---- line filter parameter VKWB ---------------------------           
extern int      RangePeriod_VKWB  = 25;
extern int      SmoothPeriod_VKWB = 3; 
input enMaTypes SmoothMode_VKWB   = ma_sma;           // Moving average method  
extern bool     alertsOn          = true;
extern bool     alertsOnCurrent   = false;
extern bool     alertsMessage     = true;
extern bool     alertsSound       = true;
extern bool     alertsEmail       = false;
extern bool     alertsNotify      = true;

//------------------------------------------------------------
double koef_ibs = 7.0;
double koef_rsi = 9.0;
double koef_cci = 1.0;

int ãëóøêà = 0;              // empty value for symmetry parameters 



bool ibs             = true; // use ibs to calculate the average lin
bool rsi             = true; // use rsi to calculate the average lin
bool cci             = true; // use cci to calculate the average lin
bool option_1        = false;// the choice of options for calculating the indicator, the default is 2 option         
int  Shift           = 0;    // bar shift
bool positive        = true; // mirror - invert 

//------------------------------------------------------------          
//---- buffers
double E0[], E1[], E2[], E3[], E4[], E5[], E6[], E7[],trend[];
int kibs=-1,kcci=-1,krsi=-1,posit=-1,xma1=1;
//------------------------------------------------------------
string indicatorFileName;
bool   returnBars;
int init(){
   IndicatorBuffers(9); 
   SetIndexBuffer(0,E0); SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,E7); SetIndexStyle(1,DRAW_LINE); 
   SetIndexBuffer(2,E5); SetIndexStyle(2,DRAW_LINE);SetIndexDrawBegin(2,SmoothPeriod_VKWB);  
   SetIndexBuffer(3,E6); SetIndexStyle(3,DRAW_LINE);SetIndexDrawBegin(3,SmoothPeriod_VKWB);
   SetIndexBuffer(4,E1);   
   SetIndexBuffer(5,E2);
   SetIndexBuffer(6,E3);
   SetIndexBuffer(7,E4);  
   SetIndexBuffer(8,trend);
    
        
   if(cci)kcci=1; if(rsi)krsi=1; if(ibs)kibs=1; 
   if(option_1)xma1=0; if(positive)posit=1;   
   
         indicatorFileName = WindowExpertName();
         returnBars        = TimeFrame==-99;
         TimeFrame         = MathMax(TimeFrame,_Period);
         //if (TimeFrame==0) TimeFrame = _Period;    
return(0);}
//------------------------------------------------------------
int deinit(){return(0);}
//------------------------------------------------------------

int start()
  {
   int  cb=IndicatorCounted();
//----
   int i,limit,limit1,limit2,n_max,n_min;
   if(cb==0){limit=Bars-1; limit1=Bars-RangePeriod_VKWB; limit2=limit1-SmoothPeriod_VKWB;}
   if(cb>0) {limit=Bars-cb; limit1=Bars-cb; limit2=limit1;}  
   limit--;limit1--;limit2--;

         if (returnBars) { E0[0] = MathMin(MathMax(MathMax(limit+1,limit1+1),limit2+1),Bars-1); return(0); }
         if (TimeFrame != _Period)
         {
            limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,TimeFrame,indicatorFileName,-99,0,0)*TimeFrame/Period()));
            for(i = limit; i >= 0; i--)
            {
               int y = iBarShift(NULL,TimeFrame,Time[i]);
                  E0[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,per_IBS,mode_IBSMa,per_RSI,app_price_RSI,per_CCI,app_price_CCI,porog,RangePeriod_VKWB,SmoothPeriod_VKWB,SmoothMode_VKWB,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsNotify,0,y);
                  E7[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,per_IBS,mode_IBSMa,per_RSI,app_price_RSI,per_CCI,app_price_CCI,porog,RangePeriod_VKWB,SmoothPeriod_VKWB,SmoothMode_VKWB,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsNotify,1,y);
                  E5[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,per_IBS,mode_IBSMa,per_RSI,app_price_RSI,per_CCI,app_price_CCI,porog,RangePeriod_VKWB,SmoothPeriod_VKWB,SmoothMode_VKWB,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsNotify,2,y);
                  E6[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,per_IBS,mode_IBSMa,per_RSI,app_price_RSI,per_CCI,app_price_CCI,porog,RangePeriod_VKWB,SmoothPeriod_VKWB,SmoothMode_VKWB,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsNotify,3,y);
            }
            return(0);
         }

   
   Delitel(E2,limit);
   for(i=limit;i>=0;i--)
   {
      E1[i]=posit*iMA_IBS_RSI_CCI(E2,per_IBS,per_RSI,per_CCI,mode_IBSMa,ãëóøêà,app_price_RSI,app_price_CCI,
                                    koef_ibs,koef_rsi,koef_cci,kibs,krsi,kcci,i+Shift);                   
   }
   for(i = limit;i>=0;i--)
   {
      E0[i]=E0[i+1];
      double raz10=E1[i]-E0[i];      
      if(fabs(raz10)>porog) 
      {
       if(raz10>0) E0[i]=E1[i]-porog*xma1;
       if(raz10<0) E0[i]=E1[i]+porog*xma1;
      }         
   } 
   for(i=limit1; i>=0;i--)
   {
      n_max = ArrayMaximum(E0,RangePeriod_VKWB,i);
      n_min = ArrayMinimum(E0,RangePeriod_VKWB,i);
      E3[i] = E0[n_max];
      E4[i] = E0[n_min];
      E5[i] = iCustomMa(SmoothMode_VKWB,E3[i],SmoothPeriod_VKWB,i,Bars,0);
      E6[i] = iCustomMa(SmoothMode_VKWB,E4[i],SmoothPeriod_VKWB,i,Bars,1);
      E7[i] =(E5[i]+E6[i])/2;
      trend[i] = (i<Bars-1) ? (E0[i]>E7[i]) ? 1 : (E0[i]<E7[i]) ? -1 : trend[i+1] : 0;
    }                             
    if (alertsOn)
    {
      int whichBar = 1; if (alertsOnCurrent) whichBar = 0;
      if (trend[whichBar] != trend[whichBar+1])
      {
         if (trend[whichBar] ==  1) doAlert(whichBar,"crossed up");
         if (trend[whichBar] == -1) doAlert(whichBar,"crossed down");
      }
    }
return(0);}
//------------------------------------------------------------
void Delitel(double& ExtMapBuffer[],int limit)
{
 double delitel;
 for(int i=limit;i>=0;i--)
 {
    delitel = High[i]-Low[i];
    if (delitel>0) ExtMapBuffer[i]= (Close[i]-Low[i])/delitel;
    else           ExtMapBuffer[i]= 0.0;
}
return;}
//------------------------------------------------------------ 
double iMA_IBS_RSI_CCI(double& ExtMapBuffer[],int tper_IBS,int tper_RSI,int tper_CCI,int tmode_Ma,
                      int tãëóøêà,int tapp_price_RSI,int tapp_price_CCI,double tkoef_ibs,double tkoef_rsi,double tkoef_cci,
                      int tkibs,int tkrsi,int tkcci,int i)
{

 double sum = 0.0;
 sum += tkibs*(iCustomMa(tmode_Ma,ExtMapBuffer[i],tper_IBS,i,Bars,2)-0.5)*100.0*tkoef_ibs;
 sum += tkcci* iCci(getPrice(tapp_price_CCI,Open,Close,High,Low,i,Bars,0),tper_CCI,i,Bars)*tkoef_cci; 
 sum += tkrsi*(iRsi(getPrice(tapp_price_RSI,Open,Close,High,Low,i,Bars,1),tper_RSI,i,Bars)-50.0)*tkoef_rsi;
 sum *= 1.0/3.0; 
return(sum);}
//------------------------------------------------------------

//
//
//
//
//

void doAlert(int forBar, string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
   if (previousAlert != doWhat || previousTime != Time[forBar]) {
       previousAlert  = doWhat;
       previousTime   = Time[forBar];
       
       //
       //
       //
       //
       //

      message = timeFrameToString(_Period)+" "+_Symbol+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" IBS RSI CCI "+doWhat;
          if (alertsMessage) Alert(message);
          if (alertsNotify)  SendNotification(message);
          if (alertsEmail)   SendMail(_Symbol+" IBS RSI CCI ",message);
          if (alertsSound)   PlaySound("alert2.wav");
   }
}

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

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

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

#define _maInstances 3
#define _maWorkBufferx1 1*_maInstances
#define _maWorkBufferx2 2*_maInstances
#define _maWorkBufferx3 3*_maInstances

double iCustomMa(int mode, double price, double length, int r, int bars, int instanceNo=0)
{
   r = bars-r-1;
   switch (mode)
   {
      case ma_sma   : return(iSma(price,(int)ceil(length),r,bars,instanceNo));
      case ma_ema   : return(iEma(price,length,r,bars,instanceNo));
      case ma_smma  : return(iSmma(price,(int)ceil(length),r,bars,instanceNo));
      case ma_lwma  : return(iLwma(price,(int)ceil(length),r,bars,instanceNo));
      case ma_slwma : return(iSlwma(price,(int)ceil(length),r,bars,instanceNo));
      case ma_dsema : return(iDsema(price,length,r,bars,instanceNo));
      case ma_tema  : return(iTema(price,(int)ceil(length),r,bars,instanceNo));
      case ma_lsma  : return(iLinr(price,(int)ceil(length),r,bars,instanceNo));
      case ma_nlma  : return(iNonLagMa(price,length,r,bars,instanceNo));
      default       : return(price);
   }
}

//
//
//
//
//

double workSma[][_maWorkBufferx1];
double iSma(double price, int period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workSma,0)!= _bars) ArrayResize(workSma,_bars);

   workSma[r][instanceNo+0] = price;
   double avg = price; int k=1;  for(; k<period && (r-k)>=0; k++) avg += workSma[r-k][instanceNo+0];  
   return(avg/(double)k);
}

//
//
//
//
//

double workEma[][_maWorkBufferx1];
double iEma(double price, double period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workEma,0)!= _bars) ArrayResize(workEma,_bars);

   workEma[r][instanceNo] = price;
   if (r>0 && period>1)
          workEma[r][instanceNo] = workEma[r-1][instanceNo]+(2.0/(1.0+period))*(price-workEma[r-1][instanceNo]);
   return(workEma[r][instanceNo]);
}

//
//
//
//
//

double workSmma[][_maWorkBufferx1];
double iSmma(double price, double period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workSmma,0)!= _bars) ArrayResize(workSmma,_bars);

   workSmma[r][instanceNo] = price;
   if (r>1 && period>1)
          workSmma[r][instanceNo] = workSmma[r-1][instanceNo]+(price-workSmma[r-1][instanceNo])/period;
   return(workSmma[r][instanceNo]);
}

//
//
//
//
//

double workLwma[][_maWorkBufferx1];
double iLwma(double price, double period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workLwma,0)!= _bars) ArrayResize(workLwma,_bars);
   
   workLwma[r][instanceNo] = price; if (period<=1) return(price);
      double sumw = period;
      double sum  = period*price;

      for(int k=1; k<period && (r-k)>=0; k++)
      {
         double weight = period-k;
                sumw  += weight;
                sum   += weight*workLwma[r-k][instanceNo];  
      }             
      return(sum/sumw);
}

//
//
//
//
//


double workSlwma[][_maWorkBufferx2];
double iSlwma(double price, double period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workSlwma,0)!= _bars) ArrayResize(workSlwma,_bars); 

   //
   //
   //
   //
   //

      int SqrtPeriod = (int)MathFloor(MathSqrt(period)); instanceNo *= 2;
         workSlwma[r][instanceNo] = price;

         //
         //
         //
         //
         //
               
         double sumw = period;
         double sum  = period*price;
   
         for(int k=1; k<period && (r-k)>=0; k++)
         {
            double weight = period-k;
                   sumw  += weight;
                   sum   += weight*workSlwma[r-k][instanceNo];  
         }             
         workSlwma[r][instanceNo+1] = (sum/sumw);

         //
         //
         //
         //
         //
         
         sumw = SqrtPeriod;
         sum  = SqrtPeriod*workSlwma[r][instanceNo+1];
            for(k=1; k<SqrtPeriod && (r-k)>=0; k++)
            {
               weight = SqrtPeriod-k;
                      sumw += weight;
                      sum  += weight*workSlwma[r-k][instanceNo+1];  
            }
   return(sum/sumw);
}

//
//
//
//
//

double workDsema[][_maWorkBufferx2];
#define _ema1 0
#define _ema2 1

double iDsema(double price, double period, int r, int _bars, int instanceNo=0)
{
   if (ArrayRange(workDsema,0)!= _bars) ArrayResize(workDsema,_bars); instanceNo*=2;

   //
   //
   //
   //
   //
   
   workDsema[r][_ema1+instanceNo] = price;
   workDsema[r][_ema2+instanceNo] = price;
   if (r>0 && period>1)
   {
      double alpha = 2.0 /(1.0+MathSqrt(period));
          workDsema[r][_ema1+instanceNo] = workDsema[r-1][_ema1+instanceNo]+alpha*(price                         -workDsema[r-1][_ema1+instanceNo]);
          workDsema[r][_ema2+instanceNo] = workDsema[r-1][_ema2+instanceNo]+alpha*(workDsema[r][_ema1+instanceNo]-workDsema[r-1][_ema2+instanceNo]); }
   return(workDsema[r][_ema2+instanceNo]);
}

//
//
//
//
//

double workTema[][_maWorkBufferx3];
#define _tema1 0
#define _tema2 1
#define _tema3 2

double iTema(double price, double period, int r, int bars, int instanceNo=0)
{
   if (ArrayRange(workTema,0)!= bars) ArrayResize(workTema,bars); instanceNo*=3;

   //
   //
   //
   //
   //
      
   workTema[r][_tema1+instanceNo] = price;
   workTema[r][_tema2+instanceNo] = price;
   workTema[r][_tema3+instanceNo] = price;
   if (r>0 && period>1)
   {
      double alpha = 2.0 / (1.0+period);
          workTema[r][_tema1+instanceNo] = workTema[r-1][_tema1+instanceNo]+alpha*(price                         -workTema[r-1][_tema1+instanceNo]);
          workTema[r][_tema2+instanceNo] = workTema[r-1][_tema2+instanceNo]+alpha*(workTema[r][_tema1+instanceNo]-workTema[r-1][_tema2+instanceNo]);
          workTema[r][_tema3+instanceNo] = workTema[r-1][_tema3+instanceNo]+alpha*(workTema[r][_tema2+instanceNo]-workTema[r-1][_tema3+instanceNo]); }
   return(workTema[r][_tema3+instanceNo]+3.0*(workTema[r][_tema1+instanceNo]-workTema[r][_tema2+instanceNo]));
}

//
//
//
//
//

double workLinr[][_maWorkBufferx1];
double iLinr(double price, int period, int r, int bars, int instanceNo=0)
{
   if (ArrayRange(workLinr,0)!= bars) ArrayResize(workLinr,bars);

   //
   //
   //
   //
   //
   
      period = MathMax(period,1);
      workLinr[r][instanceNo] = price;
      if (r<period) return(price);
         double lwmw = period; double lwma = lwmw*price;
         double sma  = price;
         for(int k=1; k<period && (r-k)>=0; k++)
         {
            double weight = period-k;
                   lwmw  += weight;
                   lwma  += weight*workLinr[r-k][instanceNo];  
                   sma   +=        workLinr[r-k][instanceNo];
         }             
   
   return(3.0*lwma/lwmw-2.0*sma/period);
}

//
//
//
//
//

#define _length  0
#define _len     1
#define _weight  2

double  nlmvalues[ ][3];
double  nlmprices[ ][_maWorkBufferx1];
double  nlmalphas[ ][_maWorkBufferx1];

//
//
//
//
//

double iNonLagMa(double price, double length, int r, int bars, int instanceNo=0)
{
   if (ArrayRange(nlmprices,0) != bars)         ArrayResize(nlmprices,bars);
   if (ArrayRange(nlmvalues,0) <  instanceNo+1) ArrayResize(nlmvalues,instanceNo+1);
                               nlmprices[r][instanceNo]=price;
   if (length<5 || r<3) return(nlmprices[r][instanceNo]);
   
   //
   //
   //
   //
   //
   
   if (nlmvalues[instanceNo][_length] != length)
   {
      double Cycle = 4.0;
      double Coeff = 3.0*M_PI;
      int    Phase = (int)(length-1);
      
         nlmvalues[instanceNo][_length] =       length;
         nlmvalues[instanceNo][_len   ] = (int)(length*4) + Phase;  
         nlmvalues[instanceNo][_weight] = 0;

         if (ArrayRange(nlmalphas,0) < (int)nlmvalues[instanceNo][_len]) ArrayResize(nlmalphas,(int)nlmvalues[instanceNo][_len]);
         for (int k=0; k<(int)nlmvalues[instanceNo][_len]; k++)
         {
            double t;
            if (k<=Phase-1) 
                  t = 1.0 * k/(Phase-1);
            else  t = 1.0 + (k-Phase+1)*(2.0*Cycle-1.0)/(Cycle*length-1.0); 
            double beta = MathCos(M_PI*t);
            double g = 1.0/(Coeff*t+1); if (t <= 0.5 ) g = 1;
      
            nlmalphas[k][instanceNo]        = g * beta;
            nlmvalues[instanceNo][_weight] += nlmalphas[k][instanceNo];
         }
   }
   
   //
   //
   //
   //
   //
   
   if (nlmvalues[instanceNo][_weight]>0)
   {
      double sum = 0;
           for (k=0; k < (int)nlmvalues[instanceNo][_len] && (r-k)>=0; k++) sum += nlmalphas[k][instanceNo]*nlmprices[r-k][instanceNo];
           return( sum / nlmvalues[instanceNo][_weight]);
   }
   else return(0);           
}

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

#define _prHABF(_prtype) (_prtype>=pr_habclose && _prtype<=pr_habtbiased2)
#define _priceInstances     2
#define _priceInstancesSize 4
double workHa[][_priceInstances*_priceInstancesSize];
double getPrice(int tprice, const double& open[], const double& close[], const double& high[], const double& low[], int i, int bars, int instanceNo=0)
{
  if (tprice>=pr_haclose)
   {
      if (ArrayRange(workHa,0)!= bars) ArrayResize(workHa,bars); instanceNo*=_priceInstancesSize; int r = bars-i-1;
         
         //
         //
         //
         //
         //
         
         double haOpen  = (r>0) ? (workHa[r-1][instanceNo+2] + workHa[r-1][instanceNo+3])/2.0 : (open[i]+close[i])/2;;
         double haClose = (open[i]+high[i]+low[i]+close[i]) / 4.0;
         if (_prHABF(tprice))
               if (high[i]!=low[i])
                     haClose = (open[i]+close[i])/2.0+(((close[i]-open[i])/(high[i]-low[i]))*fabs((close[i]-open[i])/2.0));
               else  haClose = (open[i]+close[i])/2.0; 
         double haHigh  = fmax(high[i], fmax(haOpen,haClose));
         double haLow   = fmin(low[i] , fmin(haOpen,haClose));

         //
         //
         //
         //
         //
         
         if(haOpen<haClose) { workHa[r][instanceNo+0] = haLow;  workHa[r][instanceNo+1] = haHigh; } 
         else               { workHa[r][instanceNo+0] = haHigh; workHa[r][instanceNo+1] = haLow;  } 
                              workHa[r][instanceNo+2] = haOpen;
                              workHa[r][instanceNo+3] = haClose;
         //
         //
         //
         //
         //
         
         switch (tprice)
         {
            case pr_haclose:
            case pr_habclose:    return(haClose);
            case pr_haopen:   
            case pr_habopen:     return(haOpen);
            case pr_hahigh: 
            case pr_habhigh:     return(haHigh);
            case pr_halow:    
            case pr_hablow:      return(haLow);
            case pr_hamedian:
            case pr_habmedian:   return((haHigh+haLow)/2.0);
            case pr_hamedianb:
            case pr_habmedianb:  return((haOpen+haClose)/2.0);
            case pr_hatypical:
            case pr_habtypical:  return((haHigh+haLow+haClose)/3.0);
            case pr_haweighted:
            case pr_habweighted: return((haHigh+haLow+haClose+haClose)/4.0);
            case pr_haaverage:  
            case pr_habaverage:  return((haHigh+haLow+haClose+haOpen)/4.0);
            case pr_hatbiased:
            case pr_habtbiased:
               if (haClose>haOpen)
                     return((haHigh+haClose)/2.0);
               else  return((haLow+haClose)/2.0);        
            case pr_hatbiased2:
            case pr_habtbiased2:
               if (haClose>haOpen)  return(haHigh);
               if (haClose<haOpen)  return(haLow);
                                    return(haClose);        
         }
   }
   
   //
   //
   //
   //
   //
   
   switch (tprice)
   {
      case pr_close:     return(close[i]);
      case pr_open:      return(open[i]);
      case pr_high:      return(high[i]);
      case pr_low:       return(low[i]);
      case pr_median:    return((high[i]+low[i])/2.0);
      case pr_medianb:   return((open[i]+close[i])/2.0);
      case pr_typical:   return((high[i]+low[i]+close[i])/3.0);
      case pr_weighted:  return((high[i]+low[i]+close[i]+close[i])/4.0);
      case pr_average:   return((high[i]+low[i]+close[i]+open[i])/4.0);
      case pr_tbiased:   
               if (close[i]>open[i])
                     return((high[i]+close[i])/2.0);
               else  return((low[i]+close[i])/2.0);        
      case pr_tbiased2:   
               if (close[i]>open[i]) return(high[i]);
               if (close[i]<open[i]) return(low[i]);
                                     return(close[i]);        
   }
   return(0);
}

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

double workCci[][1];
double iCci(double price, int period, int r, int bars, int instanceNo=0)
{
   if (ArrayRange(workCci,0)!= bars) ArrayResize(workCci,bars); r=bars-r-1;
   
   //
   //
   //
   //
   //
   
      workCci[r][instanceNo] = price;
         double tcci = 0;
         double avg  = 0; for(int k=0; k<period && (r-k)>=0; k++) avg +=      workCci[r-k][instanceNo];      avg /= period;
         double dev  = 0; for(    k=0; k<period && (r-k)>=0; k++) dev += fabs(workCci[r-k][instanceNo]-avg); dev /= period;
         if (dev!=0) tcci = (price-avg)/(0.015*dev);
return(tcci);
}

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

double workRsi[][3];
#define _price  0
#define _change 1
#define _changa 2

double iRsi(double price, double period, int i, int bars, int instanceNo=0)
{
   if (ArrayRange(workRsi,0)!=bars) ArrayResize(workRsi,bars);
      int z = instanceNo*3; 
      int r = bars-i-1;
   
   //
   //
   //
   //
   //
   
   workRsi[r][z+_price] = price;
         double alpha = 1.0/period; 
         if (r<period)
            {
               int k; double sum = 0; for (k=0; k<period && (r-k-1)>=0; k++) sum += fabs(workRsi[r-k][z+_price]-workRsi[r-k-1][z+_price]);
                  workRsi[r][z+_change] = (workRsi[r][z+_price]-workRsi[0][z+_price])/fmax(k,1);
                  workRsi[r][z+_changa] =                                         sum/fmax(k,1);
            }
         else
            {
               double change = workRsi[r][z+_price]-workRsi[r-1][z+_price];
                               workRsi[r][z+_change] = workRsi[r-1][z+_change] + alpha*(     change  - workRsi[r-1][z+_change]);
                               workRsi[r][z+_changa] = workRsi[r-1][z+_changa] + alpha*(fabs(change) - workRsi[r-1][z+_changa]);
            }
         if (workRsi[r][z+_changa] != 0)
               return(50.0*(workRsi[r][z+_change]/workRsi[r][z+_changa]+1));
         else  return(50.0);
   
}

These users thanked the author boytoy for the post:
ROI


Re: RSI Indicators for MT4

2453
boytoy wrote: Sun Jun 11, 2023 7:53 pm Man this is a damn good scalping indicator and without a doubt way better than the CCI on it's own. Thank you from the bottom of my heart for adding E-Averages to this indicator 😮

Man if this can be done it would be one of the most capable and complete indicators for trading - especially scalping

Only if you have time and sorry to bother you! 🙏
IBS CCI RSI with E-Averages, AHTF MTF & Outer Bands

Hello.
Here is indicator with average pack and AHTF.
These users thanked the author kvak for the post (total 15):
Gethsemane, Chickenspicy, RodrigoRT7, Jimmy, josi, ionone, boytoy, nbibu, excellence, iPar, PIPin Tom, Krunal Gajjar, Mundu19, Skyold, michaelB

Re: RSI Indicators for MT4

2455
Lightningstorm7 wrote: Fri Jun 09, 2023 10:40 am @Kvak, Greetings.. Can you please change the header conversion to change color when candles close below the average line it turns red and when candles close above the average line Green?

Thank you for the modification you've already done with this indicator!

Regards

Hi, sorry, I didn't see your post. It is better to quote me directly.
Here is your mod, I added menu and you may choose between MA or RSI header logic...
These users thanked the author kvak for the post (total 5):
Chickenspicy, RodrigoRT7, 太虚一毫, josi, Lightningstorm7


Re: RSI Indicators for MT4

2459
kvak wrote: Mon Jun 12, 2023 5:17 am IBS CCI RSI with E-Averages, AHTF MTF & Outer Bands

Hello.
Here is indicator with average pack and AHTF.
Oh my gosh Kvak you have just made my day man and I am just so grateful for this new nonrepainting IBS indicator upgrade & extended generosity to me.. Thanks to you/team I have also learned the meaning of IBS from forex station's twitter post indicator: Internal Bar Strength 💪
These users thanked the author boytoy for the post (total 4):
kvak, Jimmy, moey_dw, Mundu19


Who is online

Users browsing this forum: 88FX88, dininurin, Facebook [Crawler], lyo99, vzulaks, Yandex [Bot] and 62 guests