[MT4指标]EMA_Prediction指标
主图指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//| EMA_Prediction.mq4 |
//| Codersguru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Codersguru"
#property link "http://www.forex-tsd.com"
//----
extern int ShortEma=1;
extern int LongEma=2;
extern bool Draw_Lines=false;
//----
#property indicator_buffers 4
#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
//----
double ExtMapBuffer1;
double ExtMapBuffer2;
double ExtMapBuffer3;
double ExtMapBuffer4;
double Signal1=0,Signal2=0;
int Previous_Bar=0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_ARROW);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(0, 234);
SetIndexArrow(1, 233);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE, STYLE_SOLID,2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE, STYLE_SOLID,2);
SetIndexBuffer(3,ExtMapBuffer4);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int pos=Bars - counted_bars - 1;
while(pos>=0)
{
Signal1=0;
Signal2=0;
Previous_Bar=0;
//----
double EmaLongPrevious=iMA(NULL,0,LongEma,0,MODE_EMA, PRICE_CLOSE, pos-1);
double EmaLongCurrent=iMA(NULL,0,LongEma,0,MODE_EMA, PRICE_CLOSE, pos);
double EmaShortPrevious=iMA(NULL,0,ShortEma,0,MODE_EMA, PRICE_CLOSE, pos-1);
double EmaShortCurrent=iMA(NULL,0,ShortEma,0,MODE_EMA, PRICE_CLOSE, pos);
//----
if (Open[pos] > Close[pos]) Previous_Bar=1;
if (Open[pos] < Close[pos]) Previous_Bar=2;
if (EmaShortPreviousEmaLongCurrent && Previous_Bar==1)Signal1=High[pos];
if (EmaShortPrevious>EmaLongPrevious && EmaShortCurrentEMA_Prediction.jpg