MACD lines and Metatrader
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Dec 2006
    Location
    Maryland
    Posts
    36

    Cool MACD lines and Metatrader

    Hi all,

    Could someone please tell me how to put the slow and fast MACD lines on Metatrader. All that I am getting right now is one MACD line and a histogram.

  2. #2
    Join Date
    Jan 2007
    Posts
    13
    *bump*

    Anyone?

  3. #3
    Join Date
    Jan 2007
    Posts
    13
    Found it myself:

    Code:
    //+------------------------------------------------------------------+
    //| Custom MACD+OsMA.mq4 |
    //| Copyright  2004, MetaQuotes Software Corp. |
    //| http://www.metaquotes.net/ |
    //+------------------------------------------------------------------+
    #property copyright "Copyright  2004, MetaQuotes Software Corp."
    #property link "http://www.metaquotes.net/"
    //---- indicator settings
    #property indicator_separate_window
    #property indicator_buffers 3
    #property indicator_color1 Silver
    #property indicator_color2 Red
    #property indicator_color3 Silver
    //---- indicator parameters
    extern int FastEMA=12;
    extern int SlowEMA=26;
    extern int SignalSMA=9;
    //---- indicator buffers
    double ind_buffer1[];
    double ind_buffer2[];
    double ind_buffer3[];
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //---- drawing settings
    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
    SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
    SetIndexDrawBegin(1,SignalSMA);
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
    //---- indicator buffers mapping
    if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2) && !SetIndexBuffer(2,ind_buffer3))
    Print("cannot set indicator buffers!");
    //---- name for DataWindow and indicator subwindow label
    IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
    SetIndexLabel(0,"MACD");
    SetIndexLabel(1,"Signal");
    SetIndexLabel(2,"OsMA");
    //---- initialization done
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Moving Averages Convergence/Divergence |
    //+------------------------------------------------------------------+
    int start()
    {
    int limit;
    int counted_bars=IndicatorCounted();
    //---- check for possible errors
    if(counted_bars<0) return(-1);
    //---- last counted bar will be recounted
    if(counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;
    //---- macd counted in the 1-st buffer
    for(int i=0; i<limit; i++)
    ind_buffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
    //---- signal line counted in the 2-nd buffer
    for(i=0; i<limit; i++)
    ind_buffer2[i]=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA,i);
    for(i=0; i<limit; i++)
    ind_buffer3[i]=iOsMA(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,i);
    //---- done
    return(0);
    }

  4. #4
    Join Date
    Dec 2006
    Location
    Maryland
    Posts
    36

    Default Thanks!

    Thanks alot. I appreciate that

  5. #5
    Join Date
    Jan 2007
    Posts
    3
    I had the same dilemma, but then I figured that the bars represent the divergence/convergence of the 2 average lines. When the bar disappears in the baseline, this is when the lines have crossed!! When the bar above the baseline disappears and then reappears flipped upside-down below the baseline, the line have crossed and the short reversal has started.
    Gigio

  6. #6
    Join Date
    Nov 2006
    Posts
    14
    Check the ZeroLagMACD,more quickly than MACD
    //+------------------------------------------------------------------+
    //| ZeroLag MACD.mq4 |
    //| RD |
    //| marynarz15@wp.pl |
    //+------------------------------------------------------------------+
    #property copyright "RD"
    #property link "marynarz15@wp.pl"
    //----
    #property indicator_separate_window
    #property indicator_buffers 2
    #property indicator_color1 Blue
    #property indicator_color2 Red
    //---- input parameters
    extern int FastEMA = 12;
    extern int SlowEMA = 25;
    extern int SignalEMA = 9;
    //---- buffers
    double MACDBuffer[];
    double SignalBuffer[];
    double FastEMABuffer[];
    double SlowEMABuffer[];
    double SignalEMABuffer[];
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //---- indicators
    IndicatorBuffers(5);
    SetIndexBuffer(0, MACDBuffer);
    SetIndexBuffer(1, SignalBuffer);
    SetIndexBuffer(2, FastEMABuffer);
    SetIndexBuffer(3, SlowEMABuffer);
    SetIndexBuffer(4, SignalEMABuffer);
    SetIndexStyle(0, DRAW_LINE);
    SetIndexStyle(1, DRAW_LINE,EMPTY);
    SetIndexDrawBegin(0, SlowEMA);
    SetIndexDrawBegin(1, SlowEMA);
    IndicatorShortName("ZeroLag MACD(" + FastEMA + "," + SlowEMA + "," + SignalEMA + ")");
    SetIndexLabel(0, "MACD");
    SetIndexLabel(1, "Signal");
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custor indicator deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function |
    //+------------------------------------------------------------------+
    int start()
    {
    int limit;
    int counted_bars = IndicatorCounted();
    if(counted_bars < 0)
    return(-1);
    if(counted_bars > 0)
    counted_bars--;
    limit = Bars - counted_bars;
    double EMA, ZeroLagEMAp, ZeroLagEMAq;
    for(int i = 0; i < limit; i++)
    {
    FastEMABuffer[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
    SlowEMABuffer[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
    }
    for(i = 0; i < limit; i++)
    {
    EMA = iMAOnArray(FastEMABuffer, Bars, FastEMA, 0, MODE_EMA, i);
    ZeroLagEMAp = FastEMABuffer[i] + FastEMABuffer[i] - EMA;
    EMA = iMAOnArray(SlowEMABuffer, Bars, SlowEMA, 0, MODE_EMA, i);
    ZeroLagEMAq = SlowEMABuffer[i] + SlowEMABuffer[i] - EMA;
    MACDBuffer[i] = ZeroLagEMAp - ZeroLagEMAq;
    }
    for(i = 0; i < limit; i++)
    SignalEMABuffer[i] = iMAOnArray(MACDBuffer, Bars, SignalEMA, 0, MODE_EMA, i);
    for(i = 0; i < limit; i++)
    {
    EMA = iMAOnArray(SignalEMABuffer, Bars, SignalEMA, 0, MODE_EMA, i);
    SignalBuffer[i] = SignalEMABuffer[i] + SignalEMABuffer[i] - EMA;
    }
    return(0);
    }
    //+------------------------------------------------------------------+

  7. #7
    Blaz 86,

    The information about the code that you posted above could you please explain where that code needs to be inputed. Sorry i am a total newbie and so confused.

  8. #8
    Join Date
    Jan 2007
    Posts
    13
    Ofcourse,

    Tools/MetaQuotes Language Editor, New/Custom Indicator, Choose a name, Next, Finish. And copy/paste... or... copy/paste it in notepad and svate with extension mq4 and put it in \MetaTrader 4\experts\indicators.

    Restart MetaTrader and it's done.

  9. #9
    Thank you so much Blaz86 really appreciate it.

  10. #10
    Join Date
    Oct 2007
    Posts
    3

    Default still cant get it

    i still cant get it.

    can u guys elaborate like cut from where till where and then paste it on the notepad with save ext.

    sorry i'm too slow on forex.

Forum Sponsors

Similar Threads

  1. Help with EA and Metatrader.
    By WRX in forum Newbie Island
    Replies: 8
    Last Post: 06-25-2010, 07:38 AM
  2. macd sma and ema
    By ElGuapo in forum Newbie Island
    Replies: 2
    Last Post: 03-24-2010, 03:08 AM
  3. Windows 7 and Metatrader
    By gustofusion in forum The Melting Pot
    Replies: 0
    Last Post: 09-15-2009, 06:06 PM
  4. MB Trading and Metatrader
    By xtensive in forum Newbie Island
    Replies: 0
    Last Post: 04-17-2009, 04:42 PM
  5. Pivot Points and Metatrader
    By pippinnewbie in forum Newbie Island
    Replies: 5
    Last Post: 01-16-2007, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
"Do not confuse motion and progress. A rocking horse keeps moving but does not make any progress."
Alfred Montpert