Re: MACD indicators for MT4

101
There was an article in the 90's in TASC magazine that discussed MACD using DEMA and TEMA.
I never pursued it after coding over 10 years ago because ACD on the 15 minute took over along with confirmed zigzag on daily.

Here are the MAs and the MACDs with LSMA thrown in for fun.
I think DEMA is built in to MACD_DEMA but did not check for iCustom call.
MACD_TEMA requires Tema.

On the new build they sometimes stop plotting so might need some work.


Re: MACD indicators for MT4

102
MACD with deviations bands (it used to be called "bb macd" long time ago and was sold - and still is - for some serious $ :)). This version has the latest set of prices, and the deviations are with or without sample correction (along with some more additions - simply we have more drawing buffers available now)

These users thanked the author mladen for the post (total 2):
Jedidiah, 太虚一毫

Re: MACD indicators for MT4

103
mladen wrote: Fri May 26, 2017 12:14 am MACD with deviations bands (it used to be called "bb macd" long time ago and was sold - and still is - for some serious $ :)). This version has the latest set of prices, and the deviations are with or without sample correction (along with some more additions - simply we have more drawing buffers available now)
Professor mladen,

line 137
double price = getPrice(Price,Open,Close,High,Low,i);
instead of
double price = getPrice(Price,Open,Close,High,Low,i,Bars);
?


Re: MACD indicators for MT4

106
knaimad wrote: Fri May 26, 2017 4:15 am Yes, there is "int bars" in that function, all clear now :)
Btw: get price function that works exactly the same for mt4 and mt5 (no change of code whatsoever needed)

Code: Select all

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

#define priceInstances     1
#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; #ifdef __MQL4__ int r = bars-i-1; #else int r=i; #endif
         
         //
         //
         //
         //
         //
         
         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 (tprice>=pr_habclose)
               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);
}

Re: MACD indicators for MT4

107
mladen wrote: Fri May 26, 2017 12:14 am MACD with deviations bands (it used to be called "bb macd" long time ago and was sold - and still is - for some serious $ :)). This version has the latest set of prices, and the deviations are with or without sample correction (along with some more additions - simply we have more drawing buffers available now)


macd.png
Hi Mladen, may I please kindly request for a histrogram version for the last 4 buffer please? (6,7,8,9) Even as a standalone is fine (no need the rest)

Many thanks in advance as usual!!!

Re: MACD indicators for MT4

108
yuhu wrote: Fri May 26, 2017 8:14 am Hi Mladen, may I please kindly request for a histrogram version for the last 4 buffer please? (6,7,8,9) Even as a standalone is fine (no need the rest)

Many thanks in advance as usual!!!
Yuhu, would something like this work?
These users thanked the author mrtools for the post (total 2):
太虚一毫, Jedidiah


Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], global, Google [Bot], Grapeshot [Bot], IBM oBot [Bot], Intrest 1, Jimmy, kvak, ParallelNative, Proximic [Bot], ralf_dias, Seznam [Bot], snoopyzam, stond and 96 guests