Experiments ... - page 17

 
mladen:

Talaat E

Yes it does seem to be a good filter for false signals. Here is the histo version : macd_-_std_normalized_1_1_histo.mq4

Hi mladen again

I would appreciate if you may make it MTF for histogram version

It is really very good one

My regards

PS

using filter = 3 for E/U at 4H or D1 you may get very good results

 
talaate:

Hi mladen again

I would appreciate if you may make it MTF for histogram version

It is really very good one

My regards

PS

using filter = 3 for E/U at 4H or D1 you may get very good results

The two versions with multi time frame functionality added


 
mladen:

The two versions with multi time frame functionality added


Hi Mladen

The two files are not existed, impossible to be downloaded, please fix the links

Regards

 

 
talaate:

Hi Mladen

The two files are not existed, impossible to be downloaded, please fix the links

Regards

 

Talaat E


I know about the issue (the problem is when I upload it). I have informed the developers and they are working on a solution

 
mladen:

Talaat E


I know about the issue (the problem is when I upload it). I have informed the developers and they are working on a solution

Ok Mladen, no problem
 
Dear Mladen:
Can you help to add mtf funtion for this indicator.
cci__alma_fl.mq4
https://www.forex-tsd.com/forum/exclusive/1801381-experiments/page9

Thank you.

 
fxoni:
Dear Mladen:
Can you help to add mtf funtion for this indicator.
cci__alma_fl.mq4
https://www.forex-tsd.com/forum/exclusive/1801381-experiments/page9

Thank you.

fxoni

It will be posted as soon as the upload issue is solved

 
fxoni:
Dear Mladen:
Can you help to add mtf funtion for this indicator.
cci__alma_fl.mq4
https://www.forex-tsd.com/forum/exclusive/1801381-experiments/page9

Thank you.

Here is the code for the multi time frame version :

//------------------------------------------------------------------
#property copyright "mladen"
#property link      "www.forex-tsd.com"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1  clrDodgerBlue
#property indicator_color2  clrLightSlateGray
#property indicator_color3  clrSandyBrown
#property indicator_color4  clrSilver
#property indicator_color5  clrLimeGreen
#property indicator_color6  clrLimeGreen
#property indicator_color7  clrOrange
#property indicator_color8  clrOrange
#property indicator_style1  STYLE_DOT
#property indicator_style2  STYLE_DOT
#property indicator_style3  STYLE_DOT
#property indicator_width4  3
#property indicator_width5  3
#property indicator_width6  3
#property indicator_width7  3
#property indicator_width8  3
#property strict

//
//
//
//
//

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_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
};
enum enDoWhat
{
   do_cci,  // Make cci using alma as price filter
   do_cca,  // Make cci using alma as averaging method
   do_alm   // Make alma smoothed cci
};
enum enColorOn
{
   onSlopeChange, // Change color on slope change
   onZeroCross,   // Change color on middle level cross
   onLevelCross   // Change color on outer levels cross
};

extern ENUM_TIMEFRAMES    TimeFrame    = PERIOD_CURRENT; // Time frame to use
extern int                pperiod      = 14;          // Calculating period
extern enPrices           pprice       = pr_close;    // Price
extern int                AlmaPeriod   = 32;          // Alma period
extern double             AlmaSigma    = 6.0;         // Alma sigma
extern double             AlmaSample   = 0.25;        // Alma sample
extern enDoWhat           doWhat       = do_cci;      // Make what?
extern enColorOn          ChangeColorOn = onLevelCross; // Change colors on :
extern int                minmaxPeriod = 25;            // Period for floating zero
extern double             upLevel      = 0.90;        // Upper floating level
extern double             downLevel    = 0.10;        // Lower floating level
extern int                linesWidth   =  3;          // Lines width
extern bool               Interpolate   = true;          // Interpolate in multi time frame mode?

double buffer[];
double bufferua[];
double bufferub[];
double bufferda[];
double bufferdb[];
double trend[];
double work[];
double pricef[],zero[],up[],down[];
string indicatorFileName;
bool   returnBars;

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

int init()
{
   IndicatorBuffers(11);
   SetIndexBuffer(0,up);
   SetIndexBuffer(1,zero);
   SetIndexBuffer(2,down);
   SetIndexBuffer(3,buffer,  INDICATOR_DATA); SetIndexStyle(3,EMPTY,EMPTY,linesWidth);
   SetIndexBuffer(4,bufferua,INDICATOR_DATA); SetIndexStyle(4,EMPTY,EMPTY,linesWidth);
   SetIndexBuffer(5,bufferub,INDICATOR_DATA); SetIndexStyle(5,EMPTY,EMPTY,linesWidth);
   SetIndexBuffer(6,bufferda,INDICATOR_DATA); SetIndexStyle(6,EMPTY,EMPTY,linesWidth);
   SetIndexBuffer(7,bufferdb,INDICATOR_DATA); SetIndexStyle(7,EMPTY,EMPTY,linesWidth);
   SetIndexBuffer(8,trend   ,INDICATOR_CALCULATIONS);
   SetIndexBuffer(9,work    ,INDICATOR_CALCULATIONS);
   SetIndexBuffer(10,pricef ,INDICATOR_CALCULATIONS);
         indicatorFileName = WindowExpertName();
         returnBars        = TimeFrame==-99;
         TimeFrame         = MathMax(TimeFrame,_Period);
   IndicatorShortName(timeFrameToString(TimeFrame)+" cci alma ("+(string)pperiod+","+(string)AlmaPeriod+")");
   return(0);
}

//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit=MathMin(Bars-counted_bars,Bars-2);
         if (returnBars) { up[0] = limit+1; return(0); }
         if (TimeFrame!=Period())
         {
            limit = (int)MathMax(limit,MathMin(Bars-1,iCustom(NULL,TimeFrame,indicatorFileName,-99,0,0)*TimeFrame/Period()));
            if (trend[limit]== 1) CleanPoint(limit,bufferua,bufferub);
            if (trend[limit]==-1) CleanPoint(limit,bufferda,bufferdb);
            for (int i=limit; i>=0; i--)
            {
               int y = iBarShift(NULL,TimeFrame,Time[i]);               
                  up[i]     = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pperiod,pprice,AlmaPeriod,AlmaSigma,AlmaSample,doWhat,ChangeColorOn,minmaxPeriod,upLevel,downLevel,0,y);
                  zero[i]   = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pperiod,pprice,AlmaPeriod,AlmaSigma,AlmaSample,doWhat,ChangeColorOn,minmaxPeriod,upLevel,downLevel,1,y);
                  down[i]   = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pperiod,pprice,AlmaPeriod,AlmaSigma,AlmaSample,doWhat,ChangeColorOn,minmaxPeriod,upLevel,downLevel,2,y);
                  buffer[i] = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pperiod,pprice,AlmaPeriod,AlmaSigma,AlmaSample,doWhat,ChangeColorOn,minmaxPeriod,upLevel,downLevel,3,y);
                  trend[i]  = iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pperiod,pprice,AlmaPeriod,AlmaSigma,AlmaSample,doWhat,ChangeColorOn,minmaxPeriod,upLevel,downLevel,8,y);
                  bufferda[i] = EMPTY_VALUE;
                  bufferdb[i] = EMPTY_VALUE;
                  bufferua[i] = EMPTY_VALUE;
                  bufferub[i] = EMPTY_VALUE;

                  if (!Interpolate || (i>0 && y==iBarShift(NULL,TimeFrame,Time[i-1]))) continue;
                  
                  //
                  //
                  //
                  //
                  //
                  
                  int n,j; datetime time = iTime(NULL,TimeFrame,y);
                     for(n = 1; (i+n)<Bars && Time[i+n] >= time; n++) continue; 
                     for(j = 1; j<n && (i+n)<Bars && (i+j)<Bars; j++)
                     {
                        up[i+j]     = up[i]     + (up[i+n]    -up[i]    )*j/n;
                        zero[i+j]   = zero[i]   + (zero[i+n]  -zero[i]  )*j/n;
                        down[i+j]   = down[i]   + (down[i+n]  -down[i]  )*j/n;
                        buffer[i+j] = buffer[i] + (buffer[i+n]-buffer[i])*j/n;
                     }
            }
            for (int i=limit; i>=0; i--)
            {
               if (trend[i] ==  1) PlotPoint(i,bufferua,bufferub,buffer);
               if (trend[i] == -1) PlotPoint(i,bufferda,bufferdb,buffer);
            }             
            return(0);                  
         }

   //
   //
   //
   //
   //

   if (trend[limit]== 1) CleanPoint(limit,bufferua,bufferub);
   if (trend[limit]==-1) CleanPoint(limit,bufferda,bufferdb);
   for(int i=limit; i>=0; i--)
   {
      if (doWhat==do_cci)
            pricef[i] = iAlma(getPrice(pprice,Open,Close,High,Low,i),AlmaPeriod,AlmaSigma,AlmaSample,i);
      else  pricef[i] = getPrice(pprice,Open,Close,High,Low,i);
      double avg = 0; 
      double dev = 0; 
      if (doWhat==do_cca)
              avg = iAlma(pricef[i],AlmaPeriod,AlmaSigma,AlmaSample,i);
      else  { for(int k=0; k<pperiod && (i+k)<Bars; k++) avg += pricef[i+k];              avg /= pperiod; }
              for(int k=0; k<pperiod && (i+k)<Bars; k++) dev += MathAbs(pricef[i+k]-avg); dev /= pperiod;
      if (dev!=0)
            work[i] = (pricef[i]-avg)/(0.015*dev);
      else  work[i] = 0;
      if (doWhat==do_alm)
            buffer[i] = iAlma(work[i],AlmaPeriod,AlmaSigma,AlmaSample,i);
      else  buffer[i] = work[i];
            double min   = buffer[ArrayMinimum(buffer,minmaxPeriod,i)];
            double max   = buffer[ArrayMaximum(buffer,minmaxPeriod,i)];
            double range = max-min;
               zero[i]  = min+range*0.5;
               up[i]    = min+range*upLevel;
               down[i]  = min+range*downLevel;

         bufferda[i] = EMPTY_VALUE;
         bufferdb[i] = EMPTY_VALUE;
         bufferua[i] = EMPTY_VALUE;
         bufferub[i] = EMPTY_VALUE;
      
         //
         //
         //
         //
         //
         
         switch (ChangeColorOn)
         {
            case onLevelCross : 
                  trend[i]  = 0;
                  if (buffer[i]>up[i])   trend[i] =  1;
                  if (buffer[i]<down[i]) trend[i] = -1;
                  break;
            case onZeroCross : 
                  trend[i]  = 0;
                  if (buffer[i]>zero[i]) trend[i] =  1;
                  if (buffer[i]<zero[i]) trend[i] = -1;
                  break;
            case onSlopeChange : 
                  trend[i] = trend[i+1];
                  if (buffer[i]>buffer[i+1]) trend[i] =  1;
                  if (buffer[i]<buffer[i+1]) trend[i] = -1;
                  break;
         }
         if (trend[i] ==  1) PlotPoint(i,bufferua,bufferub,buffer);
         if (trend[i] == -1) PlotPoint(i,bufferda,bufferdb,buffer);
   }      
   return(0);
}

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

#define almaInstances 1
double  almaWork[][almaInstances];
double iAlma(double price, int period, double sigma, double sample, int r, int instanceNo=0)
{
   if (period<=1) return(price);
   if (ArrayRange(almaWork,0)!=Bars) ArrayResize(almaWork,Bars); r=Bars-r-1; almaWork[r][instanceNo] = price;
   
   //
   //
   //
   //
   //

   double m = MathFloor(sample * (period - 1.0));
   double s = period/sigma, sum=0, div=0;
   for (int i=0; i<period && (r-i)>=0; i++)
      {
         double coeff = MathExp(-((i-m)*(i-m))/(2.0*s*s));
            sum += coeff*almaWork[r-i][instanceNo];
            div += coeff;
      }
   double talma = price; if (div!=0) talma = sum/div;
   return(talma);
}

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

void CleanPoint(int i,double& first[],double& second[])
{
   if ((second[i]  != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
        second[i+1] = EMPTY_VALUE;
   else
      if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
          first[i+1] = EMPTY_VALUE;
}

//
//
//
//
//

void PlotPoint(int i,double& first[],double& second[],double& from[])
{
   if (i>=Bars-2) return;
   if (first[i+1] == EMPTY_VALUE)
         {
            if (first[i+2] == EMPTY_VALUE) 
                  { first[i]  = from[i]; first[i+1]  = from[i+1]; second[i] = EMPTY_VALUE; }
            else  { second[i] = from[i]; second[i+1] = from[i+1]; first[i]  = EMPTY_VALUE; }
         }
   else  { first[i] = from[i]; second[i] = EMPTY_VALUE; }
}

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

double workHa[][4];
double getPrice(int tprice, const double& open[], const double& close[], const double& high[], const double& low[], int i, int instanceNo=0)
{
  if (tprice>=pr_haclose)
   {
      if (ArrayRange(workHa,0)!= Bars) ArrayResize(workHa,Bars);
         int r = Bars-i-1;
         
         //
         //
         //
         //
         //
         
         double haOpen;
         if (r>0)
                haOpen  = (workHa[r-1][instanceNo+2] + workHa[r-1][instanceNo+3])/2.0;
         else   haOpen  = (open[i]+close[i])/2;
         double haClose = (open[i] + high[i] + low[i] + close[i]) / 4.0;
         double haHigh  = MathMax(high[i], MathMax(haOpen,haClose));
         double haLow   = MathMin(low[i] , MathMin(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:     return(haClose);
            case pr_haopen:      return(haOpen);
            case pr_hahigh:      return(haHigh);
            case pr_halow:       return(haLow);
            case pr_hamedian:    return((haHigh+haLow)/2.0);
            case pr_hamedianb:   return((haOpen+haClose)/2.0);
            case pr_hatypical:   return((haHigh+haLow+haClose)/3.0);
            case pr_haweighted:  return((haHigh+haLow+haClose+haClose)/4.0);
            case pr_haaverage:   return((haHigh+haLow+haClose+haOpen)/4.0);
            case pr_hatbiased:
               if (haClose>haOpen)
                     return((haHigh+haClose)/2.0);
               else  return((haLow+haClose)/2.0);        
         }
   }
   
   //
   //
   //
   //
   //
   
   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);        
   }
   return(0);
}   

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

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("");
}



 

Uploaded file (seems that now we can upload) :

Files:
 
mladen:

The two versions with multi time frame functionality added


Yes Mladen we can download now but these versions are not !!!!
macd_-_std_normalized_1_2_histo.mq4
 macd_-_std_normalized_1_2.mq4
Reason: