![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Here whenever I try to plot the MA the output is zero while the RSI plots easily.
Any help will be appreciated as I have started using the MetaTrader only recently.
#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 Black
//---- input parameters
extern int RSI_Applied_Price = 0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(h+l+c)/3,
extern int RSI_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc...
extern int RSI_Period=7;
extern int MA_Period=7;
extern int MA_Type=0; //0=SMA, 1=EMA, 2=SMMA, 3=LWMA
//---- buffers
double RSI_Minor[],RSI_7[],RSI_14[],RSI_Major[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSI_7);
SetIndexLabel(0,"RS_Minor Test");
/* SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,RS_Minor );
SetIndexLabel(1,"RMA Major ");
*/
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int limit = Bars - IndicatorCounted() - 1;
//---- indicator calculation
for(int i=limit; i>=0; i--)
{
RSI_7[i]= iRSI(NULL,0,7,0,i);
RSI_Minor[i] = iMAOnArray(RSI_7,0,7,0,MA_Type,i);
}
//----
for(i=limit; i>=0; i--)
{
}
//----
return(0);
}
//+------------------------------------------------------------------+