XMA INDICATOR QUESTION PLEASE HELP

 

Hi,


I found free indicator called XMA, I've noticed that it can be very useful, but unfortunatelly I'm totally green in MQL4.

This indicator has 5 parameters, but I only know period parameter. Could you explain me how work the rest (Porog, metod, metod2, prise)?

Please, expain me in plain english.

Additional question: How can change this indicator that it draws line in 2 colours? I know that I should change

"#property indicator_buffers 1

#property indicator_color1 Blue"


in

"#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red"


,but that's not all.


Best regards!


it's source code:


//+------------------------------------------------------------------+
//| Xma.mq4 |
//| Copyright © 2009, XrustSolution. Toys from Vinin.|
//| http://www.xrust.ucoz.net http://www.vinin.ucoz.ru |
//| xrust@land.ru xrust@gmail.com xrust@mksat.net |
//-------------------------------------------------------------------+
#property copyright "Copyright © 2008, XrustSolution."
#property link "http://www.xrust.ucoz.net"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- indicator parameters
extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
//---- buffers
double Signal[];
//+------------------------------------------------------------------+
void init(){
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(0,Signal);
IndicatorShortName("Xma"+period+porog);
return;}
//+------------------------------------------------------------------+
int start() {
int limit;
double tmp1,tmp2;
int counted_bars=IndicatorCounted();
int i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (i = limit;i>=0;i--){
tmp1=iMA(Symbol(),0,period,0,metod,prise,i);
tmp2=iMA(Symbol(),0,period,1,metod2,prise,i);
if(MathAbs(tmp1-tmp2)>=porog*Point){
Signal[i]=tmp2;
}else{
Signal[i]=Signal[i+1];
}
}
return(0);}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Xma.mq4 |
//| Copyright © 2009, XrustSolution. Toys from Vinin.|
//| http://www.xrust.ucoz.net http://www.vinin.ucoz.ru |
//| xrust@land.ru xrust@gmail.com xrust@mksat.net |
//-------------------------------------------------------------------+
#property copyright "Copyright © 2008, XrustSolution."
#property link "http://www.xrust.ucoz.net"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- indicator parameters
extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
//---- buffers
double Signal[];
//+------------------------------------------------------------------+
void init(){
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(0,Signal);
IndicatorShortName("Xma"+period+porog);
return;}
//+------------------------------------------------------------------+
int start() {
int limit;
double tmp1,tmp2;
int counted_bars=IndicatorCounted();
int i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (i = limit;i>=0;i--){
tmp1=iMA(Symbol(),0,period,0,metod,prise,i);
tmp2=iMA(Symbol(),0,period,1,metod2,prise,i);
if(MathAbs(tmp1-tmp2)>=porog*Point){
Signal[i]=tmp2;
}else{
Signal[i]=Signal[i+1];
}
}
return(0);}
//+------------------------------------------------------------------+

Files:
xma.mq4  2 kb
 

 

insomniawawa:

This indicator has 5 parameters, but I only know period parameter. Could you explain me how work the rest (Porog, metod, metod2, prise)?

Additional question: How can change this indicator that it draws line in 2 colours? I know that I should change

tmp1=iMA(Symbol(),0,period,0,metod,prise,i);
tmp2=iMA(Symbol(),0,period,1,metod2,prise,i);
if(MathAbs(tmp1-tmp2)>=porog*Point){
  1. double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift) so metod/metod2 are the method, prise is the applied price and porog is how many points the current and secondary must differ or the line doesn't change.
  2. There is only one buffer, you'll have to add a second, decide what the two colors represent and fill each approprately. Look at any colored indicator to see how it's down.
  3. Use SRC
  4. No Slaves here, learn to code or pay someone. We're not going to code it FOR you. We are willing to HELP you.
 
Thank you for your help! I only don't understand one thing, there are two methods and both are used at the same time. What's the difference between them?
 
insomniawawa:
Thank you for your help! I only don't understand one thing, there are two methods and both are used at the same time. What's the difference between them?

Constant Value Description
MODE_SMA 0 Simple moving average,
MODE_EMA 1 Exponential moving average,
MODE_SMMA 2 Smoothed moving average,
MODE_LWMA 3 Linear weighted moving average.
Reason: