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.
DEMA.mq4
(2.58 KiB) Downloaded 814 times
Tema.mq4
(2.97 KiB) Downloaded 820 times
MACD_DEMA.mq4
(4.19 KiB) Downloaded 870 times
MACD_TEMA.mq4
(3.58 KiB) Downloaded 874 times
MACD_LSMA.mq4
(3.73 KiB) Downloaded 772 times


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)

macd.png
macd with standard deviations 1.01.mq4
(11.99 KiB) Downloaded 955 times

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

#104
knaimad wrote:
Fri May 26, 2017 3:50 am
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);
?
Check the get price function


Re: MACD indicators for MT4

#106
knaimad wrote:
Fri May 26, 2017 4:15 am
mladen wrote:
Fri May 26, 2017 4:02 am

Check the get price function
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
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!!!
Yuhu, would something like this work?
macd with standard deviations 1.01 Histo.mq4
(10.71 KiB) Downloaded 815 times
macd std histo.png

Re: MACD indicators for MT4

#109
mrtools wrote:
Fri May 26, 2017 11:11 am
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?
Dear Mr Tools, yes, that is exactly what i want. Very many thanks as always for your kind help. I very much appreciate it!


Users viewing this forum: behar, CommonCrawl [Bot], DotNetDotCom [Bot], ffsss, fxmoney, Gethsemane, Google Feedfetcher, Greg82, Intrest 1, Jonex1995, knglerxst, kvak, LUCAS123, PIPin Tom, Ruby [Bot], shinnosuke, Steam1, vvFish, WhatsApp [Bot], xard777 and 87 guests