Can Someone Make This MACD Indicator

R

ron4bama

New member
I bought a book that came with a free indicator for MT4 and also the codes. With the purchase of the book I have permission to use the codes to make an indicator for TOS.
 
H

horserider

Well-known member
VIP
Warehouse
There are so many MACD variations already. Hard to believe it could be something much different than one of those. Why not show a chart or the code and see what happens.
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@ron4bama Post the code if you need help converting it.
 
R

ron4bama

New member
Code:
//+------------------------------------------------------------------+

//|                                                MACD_Platinum.mq4 |

//|                                     [email protected] |

//|                               http//www.wix.com/wiseea/wise-ea#! |

//+------------------------------------------------------------------+

#property description   "Version 1.00"

#property description   "Updated on 08/29/2017"

//+------------------------------------------------------------------+

//| Setup & Include                                                  |

//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 10

#property indicator_color1 RoyalBlue

#property indicator_color2 IndianRed

#property indicator_color3 Turquoise

#property indicator_color4 OrangeRed

#property indicator_width1 1

#property indicator_width2 2

#property indicator_width3 1

#property indicator_width4 1

#property indicator_level1 0.0

//+------------------------------------------------------------------+

//| Input parameters                                                 |

//+------------------------------------------------------------------+

input int  Fast               = 12;

input int  Slow               = 26;

input int  Smooth             = 9;

input bool ZeroLag            = true;

input bool ShowMarkersOnCross = true;

input bool PopUp_Alert        = true;

input bool PushNotifications  = false;

//+------------------------------------------------------------------+

//| Global variabels                                                 |

//+------------------------------------------------------------------+

double Macd[];             // = 0

double Avg[];              // = 1

double MarkersUp[];        // = 2

double MarkersDown[];      // = 3

//----

double fastEma[];    // = 4

double slowEma[];    // = 5

double avgEma[];     // = 6

double fastEmaEma[]; // = 7

double slowEmaEma[]; // = 8

double avgEmaEma[];  // = 9

//----

int    Multiplier = 10;   // forex multiplier from Ninja version

static datetime dt;

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int init()

  {

//----

   SetIndexBuffer(0, Macd);

   SetIndexStyle (0, DRAW_LINE,STYLE_DOT,EMPTY);

   SetIndexLabel (0,"Macd"); 

   SetIndexBuffer(1, Avg);

   SetIndexStyle (1, DRAW_LINE,EMPTY,EMPTY);

   SetIndexLabel (1,"Avg"); 

   SetIndexBuffer(2, MarkersUp);

   SetIndexStyle (2, DRAW_ARROW,EMPTY,1);

   SetIndexArrow (2, 108);

   SetIndexLabel (2,"UpCross"); 

   SetIndexBuffer(3, MarkersDown);

   SetIndexStyle (3, DRAW_ARROW,EMPTY,1);

   SetIndexArrow (3, 108);

   SetIndexLabel (3,"DnCross");

//----   

   SetIndexBuffer(4, fastEma);

   SetIndexStyle (4, DRAW_NONE); SetIndexLabel (8,NULL);

   SetIndexBuffer(5, slowEma);

   SetIndexStyle (5, DRAW_NONE); SetIndexLabel (9,NULL);

   SetIndexBuffer(6, avgEma);

   SetIndexStyle (6, DRAW_NONE); SetIndexLabel (10,NULL);

   SetIndexBuffer(7, fastEmaEma);

   SetIndexStyle (7, DRAW_NONE); SetIndexLabel (11,NULL);

   SetIndexBuffer(8, slowEmaEma);

   SetIndexStyle (8, DRAW_NONE); SetIndexLabel (12,NULL);

   SetIndexBuffer(9, avgEmaEma);

   SetIndexStyle (9, DRAW_NONE); SetIndexLabel (13,NULL); 

//---- name for DataWindow and indicator subwindow label

   string short_name="MACD_Platinum(" + Fast + ", " + Slow + ", " + Smooth +")";

   IndicatorShortName(short_name);

   IndicatorDigits(4);

   dt=0;

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function                       |

//+------------------------------------------------------------------+

int deinit()

  {

//----

//----

   return (0);

  }

//+------------------------------------------------------------------+

//| MACD_Platinum main function                                      |

//+------------------------------------------------------------------+

int start()

  {

//----

   int limit, counted_bars=IndicatorCounted();

   limit=Bars-Slow+1;

   if(counted_bars>0) limit=Bars-counted_bars-1;

//----   

   for (int i=limit; i>=0; i--)

     {

      double macd=0;

      double macdAvg=0;

      //---- 

      if (!ZeroLag)

        {

         fastEma = ((2.0 / (1 + Fast)) * (Multiplier*Close) + (1 - (2.0 / (1 + Fast))) * fastEma[i+1]);

            slowEma = ((2.0 / (1 + Slow)) * (Multiplier*Close) + (1 - (2.0 / (1 + Slow))) * slowEma[i+1]);

            macd          = fastEma[i+0] - slowEma[i+0];

            macdAvg      = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * Avg[i+1];

           Macd    = macd;

            Avg     = macdAvg;

          }

       else

          {   

         fastEma    = ((2.0 / (1 + Fast)) * (Multiplier*Close) + (1 - (2.0 / (1 + Fast))) * fastEma[i+1]);

            slowEma    = ((2.0 / (1 + Slow)) * (Multiplier*Close) + (1 - (2.0 / (1 + Slow))) * slowEma[i+1]);

         fastEmaEma = (2.0 / (1 + Fast)) * fastEma + (1 - (2.0 / (1 + Fast))) * fastEmaEma[i+1];

         slowEmaEma = (2.0 / (1 + Slow)) * slowEma + (1 - (2.0 / (1 + Slow))) * slowEmaEma[i+1];

         double differenceFast = fastEma - fastEmaEma;

         double differenceSlow = slowEma - slowEmaEma;

         macd          = ((fastEma+differenceFast) - (slowEma+differenceSlow));             

         Macd       = (macd);

         avgEma     = (2.0 / (1 + Smooth)) * Macd   + (1 - (2.0 / (1 + Smooth))) * avgEma[i+1];

            avgEmaEma  = (2.0 / (1 + Smooth)) * avgEma + (1 - (2.0 / (1 + Smooth))) * avgEmaEma[i+1];

         double differenceAvg = avgEma - avgEmaEma;

         macdAvg = avgEma + differenceAvg;

         Avg  = (macdAvg);

        }

      //---- markers

      MarkersUp  = EMPTY_VALUE;

      MarkersDown= EMPTY_VALUE;   

      if (i>=1 && ShowMarkersOnCross)

        {

         if (Macd > Avg && Macd[i+1] <= Avg[i+1])

           {

            MarkersUp = Avg;

            if (i==1 && dt<Time[0]) alert_sig("Up Cross!");

           }   

         else if (Macd < Avg && Macd[i+1] >= Avg[i+1])

           {

            MarkersDown = Avg;

            if (i==1 && dt<Time[0]) alert_sig("Dn Cross!");

           }

        }

     }

//---- 

   return(0);

  }

//**

//**

//+------------------------------------------------------------------+

//| FUNCTIONS: Send alerts                                           |

//+------------------------------------------------------------------+

void alert_sig(string comstr)

  {

//----

   string body=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES)+" | MACD_Platinum | "+comstr;

   if (PopUp_Alert) Alert(body);

   if (PushNotifications) SendNotification(body);

   dt=Time[0];

  }
 
markos

markos

Well-known member
VIP
Warehouse
There are so many MACD variations already. Hard to believe it could be something much different than one of those. Why not show a chart or the code and see what happens.
@horserider any idea why a Forex Multiplier of 10 is in a standard Zero Lag MACD? Otherwise, I don't see anything "special" compared to the other ZL-MACD's we have seen.
 
R

ron4bama

New member
No, I don't know anything about it, just seeing if I can get it converted or if someone can offer something that's already made
 
markos

markos

Well-known member
VIP
Warehouse
@ron4bama please use Imgur.com, copy their BBCode and paste it here. It's free.
 
H

horserider

Well-known member
VIP
Warehouse
@markos Not familiar with zero lag MACD. Why would a forex multiplier be in a MACD study ? I know that is what you asked.
 

Top