//+------------------------------------------------------------------+
//| The Simple Moving Average.mq4 |
//| Takitano |
//|
Forex Trading Software: forex Trading Platform
metatrader 4 |
//+------------------------------------------------------------------+
#property copyright "Takitano"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
//---- input parameters
double Buffer_MA[];
double Buffer_ot[];
double Buffer_ot1[];
extern int MA=50;
extern int TimeFrame=0;
double Spread=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
Spread = MarketInfo(Symbol(),MODE_SPREAD);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Buffer_MA);
SetIndexDrawBegin(0,MA);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Buffer_ot);
SetIndexDrawBegin(0,MA);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,Buffer_ot1);
SetIndexDrawBegin(0,MA);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
double MOVING_AVERAGE; //current MA 50 shift = 0
for(int i=0; i<limit; i++)
{
Buffer_MA[i]=iMA(NULL,TimeFrame,MA,0,MODE_SMA,PRICE_CLOSE,i);
}
for(i=0; i<limit; i++)
{
Buffer_ot1[i]= Buffer_MA[i]+ 50* (Buffer_MA[i]-Buffer_MA[i+2])/2;
}
//----
return(0);
}
//+------------------------------------------------------------------+