Please help me.
Simple MA Code by MQL4
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_style1 STYLE_DOT
#property indicator_width1 2
#property indicator_color1 Blue
//---- input parameters
extern int MAPeriod = 20;
//---- buffers
double ma[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ma);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)
{
ma[i] = iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i);
}
return(0);
}
//+------------------------------------------------------------------+
have 3 issuses.
1. not STYLE_DOT
2. not width 2
3. Unnecessary line on the right side of the current Bar displays
Attachment:
ma.mt4.png [21.75 KiB]
Downloaded 200 times