Adding MA to an Indicator

 

If someone would be kind enough to help me here. I want to add a moving average to CCI, Stochastic and MACD. But as I am new to this system I cannot figure it out. I know it can be done. Any help would be greatly appriecated

 
PeaceLover:
If someone would be kind enough to help me here. I want to add a moving average to CCI, Stochastic and MACD. But as I am new to this system I cannot figure it out. I know it can be done. Any help would be greatly appriecated

Hi PeaceLover,

Very good nick name!

Do you mean you want to get the moving average of CCI,Stochastic and MACD main indicator value? If yes! Please go to this article:

http://www.metatrader.info/node/84

 
codersguru:
Hi PeaceLover,

Very good nick name!

Do you mean you want to get the moving average of CCI,Stochastic and MACD main indicator value? If yes! Please go to this article:

http://www.metatrader.info/node/84

Codersguru

Thank you for the quick reply. I did see the link but could not understand how to get it done. Please keep in mind that I am new to this system.

Once again thank you for the info.

 

Please

how to drag the moving average ?

should we hold "shift" botton or somthing

 

Adding MA

PeaceLover:
If someone would be kind enough to help me here. I want to add a moving average to CCI, Stochastic and MACD. But as I am new to this system I cannot figure it out. I know it can be done. Any help would be greatly appriecated

If you mean that you have CCI, Stochastic or MACD already displayed and you want to add a MA to the existing indicators displayed. Open up the Navigator treeon the left of the chart select Moving Average ( out of the INDICATORS not CUSTOM INDICATORS ) by clicking left mouse button once, Now click and hold down the left mouse button on the highlighted indicator in the list and drag the small rectangle symbol over to the displayed indicator window and release the mouse button, a box will appear , select Parameters and go to the Apply tobox, next select Previous Indicator Dataand click OK and there you have it.

 

heres a cci with MA i was tring to make awhile back it has some redundant code but should work. ill rewrite it when i get some time

https://c.mql5.com/forextsd/forum/162/zigzagphatb.mq4

 

looks like you closed your for i loop before placing your imonarray

so u could do something like

int start()

{

double MA, RSI[];

ArrayResize(RSI,BandPeriod);

int counted_bars=IndicatorCounted();

int limit = Bars-counted_bars-1;

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

{

RSIBuf = iRSI(NULL,0,RSIPeriod,MODE_CLOSE,i);

MA = 0;

for(int j=i; j<i+BandPeriod; j++) {

RSI[j-i] = RSIBuf[j];

MA += RSIBuf[j]/BandPeriod;

}

{

RSIBufdot = iRSI(NULL,0,RSIPeriod,MODE_CLOSE,i);

}

UpZone = MA + (1.3185 * StDev(RSI,BandPeriod));

DnZone = MA - (1.3185 * StDev(RSI,BandPeriod));

UpZonei = MA + (0.68 * StDev(RSI,BandPeriod));

DnZonei = MA - (0.68 * StDev(RSI,BandPeriod));

}

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

{

SignalMABuf=iMAOnArray(RSIBuf,0,SignalMAPeriod,0,MODE_EMA,i);

}
 

Adding indi to the same window.

kappari:
Please

how to drag the moving average ?

should we hold "shift" botton or somthing

Ok, this is what I found out and thanks to the guy who answered my request.

press Ctrl + N

select the indi from the window and click and drag it to the indi window you want it on. If you are adding a moving average on the 3 option in the setup window select previous indicator.

Hope this helps

 
cja:
If you mean that you have CCI, Stochastic or MACD already displayed and you want to add a MA to the existing indicators displayed. Open up the Navigator treeon the left of the chart select Moving Average ( out of the INDICATORS not CUSTOM INDICATORS ) by clicking left mouse button once, Now click and hold down the left mouse button on the highlighted indicator in the list and drag the small rectangle symbol over to the displayed indicator window and release the mouse button, a box will appear , select Parameters and go to the Apply tobox, next select Previous Indicator Dataand click OK and there you have it.

Thank you for the help

Peace out

 

Thank You LowPhat

That did the trick. I'm looking at the code and logging in the old noggin where i needed to place things to make it work the next time i attemp something similar. Thank you for the daily lesson : )

Cheers,

Thom

 

CG...Can this work??

Greetings all.

Ahamed, i read your article (and am going through your course, great info!)

I followed the directions in your article posted above on placing an MA on an indicator. I known that this code i've posted below is very, very close. Is it possible to point out what needs to be tweaked for the MA to show up? There are no errors listed, but i'm not seeing the moving average of the RSI. I wanted to use it as a signal line. I was able to add a second set of Bollinger Bands, and also place a second RSI line drawn in dots for use as a visual on candle close...Then the signal line was going to be based on the RSI. . .I know it is something simple i'm missing.

The signal buffer i named : "SignalMABuf", and also have an extern named "SignalMAPeriod" in case one wishes to change the MA period.

The line of code i inserted thanks to your article is this:

SignalMABuf=iMAOnArray(RSIBuf,0,SignalMAPeriod,0,MODE_EMA,i);

Thanks in advance for your time and insights : )

: ) Thom

Here is the whole code:

/*+---------------------------------------------------------------------------------+

| Original file from Dynamic Zone RSI.mq4 polk@alba.dp.ua © 2005, Pavel Kulko |

| Modyfied with Dual BBands, RSI Reversal Indicator Dots & Signal Line |

| By Accrete at accrete.com c2006 Dynamic Zone RSI DualBBtrigger |

+---------------------------------------------------------------------------------+

*/

#property copyright "Copyright © 2005, Pavel Kulko"

#property link "polk@alba.dp.ua"

#property indicator_buffers 7

#property indicator_color1 Lime

#property indicator_color2 Red

#property indicator_color3 Blue

#property indicator_color4 Red

#property indicator_color5 Blue

#property indicator_color6 Aqua

#property indicator_color7 Yellow

#property indicator_separate_window

extern int RSIPeriod = 8;

extern int SignalMAPeriod=8;

extern int BandPeriod = 21;

double RSIBuf[],UpZone[],DnZone[],UpZonei[],DnZonei[],RSIBufdot[],SignalMABuf[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,RSIBuf);

SetIndexStyle(1,DRAW_LINE);

SetIndexBuffer(1,UpZone);

SetIndexStyle(2,DRAW_LINE);

SetIndexBuffer(2,DnZone);

SetIndexStyle(3,DRAW_LINE,2,1);

SetIndexBuffer(3,UpZonei);

SetIndexStyle(4,DRAW_LINE,2,1);

SetIndexBuffer(4,DnZonei);

SetIndexStyle(5,DRAW_ARROW, EMPTY);

SetIndexArrow(5,115);

SetIndexBuffer(5,RSIBufdot);

SetIndexStyle(6,DRAW_LINE,2,1);

SetIndexBuffer(6,SignalMABuf);

//----

return(0);

}

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

//| Custor indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

double MA, RSI[];

ArrayResize(RSI,BandPeriod);

int counted_bars=IndicatorCounted();

int limit = Bars-counted_bars-1;

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

{

RSIBuf = iRSI(NULL,0,RSIPeriod,MODE_CLOSE,i);

MA = 0;

for(int j=i; j<i+BandPeriod; j++) {

RSI[j-i] = RSIBuf[j];

MA += RSIBuf[j]/BandPeriod;

}

{

RSIBufdot = iRSI(NULL,0,RSIPeriod,MODE_CLOSE,i);

}

UpZone = MA + (1.3185 * StDev(RSI,BandPeriod));

DnZone = MA - (1.3185 * StDev(RSI,BandPeriod));

UpZonei = MA + (0.68 * StDev(RSI,BandPeriod));

DnZonei = MA - (0.68 * StDev(RSI,BandPeriod));

}

{

SignalMABuf=iMAOnArray(RSIBuf,0,SignalMAPeriod,0,MODE_EMA,i);

}

//----

return(0);

}

double StDev(double& Data[], int Per)

{

return(MathSqrt(Variance(Data,Per)));

}

double Variance(double& Data[], int Per)

{

double sum, ssum;

for (int i=0; i<Per; i++)

{

sum += Data;

ssum += MathPow(Data,2);

}

return((ssum*Per - sum*sum)/(Per*(Per-1)));

}

//+------------------------------------------------------------------+
Reason: