Download MetaTrader 5

MACD changing ema

To add comments, please log in or register
iasker11
16
iasker11  

Hello

Can you help me for macd code

Macd=ima12-ima26

newMacd

a=ima5  

b=ima12(ima5)

c=ima26(ima5)

newMacd=b-c

Thanks.

whroeder1
17512
whroeder1  
iasker11: Can you help me
Help you with what? You haven't stated a problem. Show us your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
iasker11
16
iasker11  
//+------------------------------------------------------------------+
//|                                                     MA_of_MA.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Wolfe"
#property link ""

#property indicator_separate_window
//#property indicator_minimum 0
//#property indicator_maximum 100
//#property indicator_level1  20
//#property indicator_level2  80
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Red

extern int  MA_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc...
extern int  MA_Period =3;
extern int  MA_Method=1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
extern int  MA_Applied_Price=0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4
extern int  MA1_of_MA_Period = 7;
extern int  MA1_of_MA_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
extern int  MA2_of_MA_Period = 14;
extern int  MA2_of_MA_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA

double MA1_Array[],MA2_Array[],MA[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_DASH,1);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName("MA_of_MA "+MA_Timeframe);

SetIndexBuffer(0,MA1_Array);
SetIndexLabel(0,"MA1-MA "+MA1_of_MA_Period);

SetIndexBuffer(1,MA2_Array);
SetIndexLabel(1,"MA2-MA "+MA2_of_MA_Period);

SetIndexBuffer(2,MA);
SetIndexLabel(2,"MA "+MA_Period);

return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit = Bars - IndicatorCounted() - 1;

//---- indicator calculation

   for(int i=limit; i>=0; i--)
   {
    MA[i] = iMA(NULL,MA_Timeframe,MA_Period,0,MA_Method,MA_Applied_Price,i);
   }
    
   for(i=limit; i>=0; i--)
   { 
    MA1_Array[i] = iMAOnArray(MA,0,MA1_of_MA_Period,0,MA1_of_MA_Method,i);
    MA2_Array[i] = iMAOnArray(MA,0,MA2_of_MA_Period,0,MA2_of_MA_Method,i);
   }
//----
return(0);
}
//+------------------------------------------------------------------+
Naguisa Unada
217
Naguisa Unada  
 //+------------------------------------------------------------------+ 
 //|                                                     MA_of_MA.mq4 | 
 //|                                                                  | 
 //|                                                                  | 
 //+------------------------------------------------------------------+ 
 #property  copyright "Wolfe" 
 #property  link "" 

 #property  indicator_separate_window 
 //#property indicator_minimum 0 
 //#property indicator_maximum 100 
 //#property indicator_level1  20 
 //#property indicator_level2  80 
 #property  indicator_buffers 2 
 #property  indicator_color1 Yellow
 #property  indicator_color2 Blue
 //#property indicator_color3 Red 

 extern int   MA_Timeframe= 0 ; //0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc... 
 extern int   MA_Period = 3 ;
 extern int   MA_Method= 1 ; // 0=SMA, 1=EMA, 2=SMMA, 3=LWMA 
 extern int   MA_Applied_Price= 0 ; //0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4 
 extern int   MA1_of_MA_Period = 7 ;
 extern int   MA1_of_MA_Method = 1 ; // 0=SMA, 1=EMA, 2=SMMA, 3=LWMA 
 extern int   MA2_of_MA_Period = 14 ;
 extern int   MA2_of_MA_Method = 1 ; // 0=SMA, 1=EMA, 2=SMMA, 3=LWMA 
 extern int   Signal_period = 5 ;

 double MA1_Array[],MA2_Array[],MA[];

 //+------------------------------------------------------------------+ 
 //| Custom indicator initialization function | 
 //+------------------------------------------------------------------+ 
 int init()
{
 //---- indicators setting 
 IndicatorBuffers ( 3 );
 SetIndexStyle ( 0 , DRAW_LINE , STYLE_SOLID , 1 );
 SetIndexStyle ( 1 , DRAW_LINE , STYLE_SOLID , 1 );
 //SetIndexStyle(2,DRAW_LINE,STYLE_DASH,1); 

 IndicatorDigits ( MarketInfo ( Symbol (), MODE_DIGITS ));
 IndicatorShortName ( "MA_of_MA " +MA_Timeframe);

 SetIndexBuffer ( 0 ,MA1_Array);
 SetIndexLabel ( 0 , "MA1-MA " +MA1_of_MA_Period);

 SetIndexBuffer ( 1 ,MA2_Array);
 SetIndexLabel ( 1 , "MA2-MA " +MA2_of_MA_Period);

 SetIndexBuffer ( 2 ,MA);
 //SetIndexLabel(2,"MA "+MA_Period); 

 return ( 0 );
}

 //+------------------------------------------------------------------+ 
 //| Custom indicator iteration function | 
 //+------------------------------------------------------------------+ 
 int start()
{
 int limit = Bars - IndicatorCounted () - 1 ;

 //---- indicator calculation 

   for ( int i=limit; i>= 0 ; i--)
   {
    MA[i] = iMA ( NULL ,MA_Timeframe,MA_Period, 0 ,MA_Method,MA_Applied_Price,i);
   }
    
   for (i=limit; i>= 0 ; i--)
   { 
     //MA1_Array[i] = iMAOnArray(MA,0,MA1_of_MA_Period,0,MA1_of_MA_Method,i); 
     //MA2_Array[i] = iMAOnArray(MA,0,MA2_of_MA_Period,0,MA2_of_MA_Method,i); 
     double MA1 = iMAOnArray (MA, 0 ,MA1_of_MA_Period, 0 ,MA1_of_MA_Method,i);
     double MA2 = iMAOnArray (MA, 0 ,MA2_of_MA_Period, 0 ,MA2_of_MA_Method,i);
    
    MA1_Array[i] = MA1 - MA2;
   }
   
   for (i=limit; i>= 0 ; i--)
        MA2_Array[i] = iMAOnArray (MA1_Array, 0 , Signal_period, 0 , MODE_SMA , i);
 //---- 
 return ( 0 );
}
 //+------------------------------------------------------------------+ 

Multi-timeframes do not work with this program.

You need to get used to the new format.

iasker11
16
iasker11  

Thanks for helping.

To add comments, please log in or register