Dema Lines

 

Hi,

I tried to plot three lines, Dema 4 (period =4), Dema 12 (period=12), Wma150 (weighted ,period=150) butit only plot the weighted moving avrage with period 150.

Kindly

//+------------------------------------------------------------------+
//|                       DEMA_RLH                                   |
//|             Copyright © 2006, Robert Hill                        |                                          
//|                http://www.metaquotes.net/                        |
//|                    (With Alterations)                            |

  |               Link to original code:                        |

| https://forex-indicators.net/files/indicators/mt4/DEMA_RLH.mq4 |
//| Based on the formula developed by Patrick Mulloy                 | //|                                                                  | //| It can be used in place of EMA or to smooth other indicators.    | //|                                                                  | //| DEMA = 2 * EMA - EMA of EMA                                      | //|                                                                  | //| SkyBlue is DEMA4, White is DEMA12, Yellow is WMA150                 | //|                                                                  | //+------------------------------------------------------------------+ #property  link      "http://www.metaquotes.net/" //---- indicator settings #property  indicator_chart_window #property  indicator_buffers 3 #property  indicator_color1  SkyBlue #property  indicator_color2  White #property  indicator_color3  Yellow #property  indicator_width1  2 #property  indicator_width2  2 #property  indicator_width3  2 //---- extern int EMA_Period4=4; extern int EMA_Period12=12; extern int WMA_Period150=150; //---- buffers double Dema4[]; double Dema12[]; double Ema4[]; double Ema12[]; double EmaOfEma4[]; double EmaOfEma12[]; double Wma150[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function                         | //+------------------------------------------------------------------+ int init()   { //---- drawing settings    SetIndexStyle(0,DRAW_LINE);    SetIndexStyle(1,DRAW_LINE);    SetIndexStyle(2,DRAW_LINE); //---    SetIndexDrawBegin(0,EMA_Period4);    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping    SetIndexBuffer(0,Dema4);    SetIndexBuffer(1,Dema12);    SetIndexBuffer(2,Wma150); //---- name for DataWindow and indicator subwindow label    IndicatorShortName("DEMA("+EMA_Period4+")"); //---- initialization done    return(0);   } //+------------------------------------------------------------------+ //|                                                                  | //+------------------------------------------------------------------+ int start()   {    int i;    int counted_bars = IndicatorCounted();    if(counted_bars < 0)  return(-1);    if(counted_bars > 0)   counted_bars--;    int limit4 = Bars - counted_bars;    int limit12 = Bars - counted_bars;    int limit150 = Bars - counted_bars;       if(counted_bars==0) limit4-=1+EMA_Period4;    if(counted_bars==0) limit12-=1+EMA_Period12;    if(counted_bars==0) limit150-=1+WMA_Period150;       //----    for(i=limit4; i>=0; i--) Ema4[i]=iMA(NULL,0,EMA_Period4,0,MODE_EMA,PRICE_CLOSE,i);    for(i=limit4; i >=0; i--) EmaOfEma4[i]=iMAOnArray(Ema4,0,EMA_Period4,0,MODE_EMA,i);                  for(i=limit4; i >=0; i--) Dema4[i]=2 * Ema4[i] - EmaOfEma4[i];           for(i=limit12; i>=0; i--) Ema12[i]=iMA(NULL,0,EMA_Period12,0,MODE_EMA,PRICE_CLOSE,i);    for(i=limit12; i >=0; i--) EmaOfEma12[i]=iMAOnArray(Ema12,0,EMA_Period12,0,MODE_EMA,i);                  for(i=limit12; i >=0; i--) Dema12[i]=2 * Ema12[i] - EmaOfEma12[i];      for(i=limit150; i>=0; i--) Wma150[i]=iMA(NULL,0,WMA_Period150,0,MODE_LWMA,PRICE_CLOSE,i);                   return(0);   } //+------------------------------------------------------------------+ //-----------+


help.

 
chua le:

Hi,

I tried to plot three lines, Dema 4 (period =4), Dema 12 (period=12), Wma150 (weighted ,period=150) butit only plot the weighted moving avrage with period 150.

Kindly


help.

It has only three buffers.

 
oh, thank you , idontquite understand, how many buffers i require?
 
Is it correct I only need 3 buffers since I only draw 3 lines, Dema4, Dema12 and Wma150?
 
No, you also have to prepare buffers for EMA4, EMA12, EmaOfEma4, and EmaOfEma12.
 
chua le:
Is it correct I only need 3 buffers since I only draw 3 lines, Dema4, Dema12 and Wma150?
You have already put your initials on top of this source code, of which you are not the author. And now you come here to have us fix it for you. Is this correct?
 
Naguisa Unada:
No, you also have to prepare buffers for EMA4, EMA12, EmaOfEma4, and EmaOfEma12.

i see thank you

 
lippmaje:
You have already put your initials on top of this source code, of which you are not the author. And now you come here to have us fix it for you. Is this correct?

It is altered from the original code, so what shall i do? 

 
chua le:

It is altered from the original code, so what shall i do? 

First of all by adding this:

#property  copyright "Copyright © 2006, Robert Hill "

and then add some remark that it's modified/enhanced by you.


Link to original code:

https://forex-indicators.net/files/indicators/mt4/DEMA_RLH.mq4

 
ok thanks
 

Hi,


I added buffers and all the 7 lines (Dema4,  Dema12, Wma150,  Ema4, Ema12, EmaOfEma4, EmaOfEma12 ) are displayed, Ema4, Ema12, EmaOfEma4, EmaOfEma12 in black colors.  I only need to display Dema4, Dema12 and Wma150, how to hide Ema4, Ema12, EmaOfEma4, EmaOfEma12 ?


Regards

Reason: