كود:
//+------------------------------------------------------------------+
//| Wizard_gsm_indicator V1.mq4 |
//| Copyright © 2020 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Wizard_gsm"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1
extern int MA_Period=200;
extern int MA_Type = 1;
extern int App_Price = 0 ;
bool SoundON=false;
bool EmailON=false;
double CrossUp[];
double CrossDown[];
double pt;
int flagval1 = 0;
int flagval2 = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if(Digits==4 || Digits<=2) pt=Point;
if(Digits==5 || Digits==3) pt=Point*10;
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 225);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 226);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i;
double tmp=0;
bool CrossedUp = false, CrossedDown = false;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = 1; i <= limit; i++) {
double MA_ = iMA(Symbol(),0,MA_Period,0,MA_Type,App_Price,i);
CrossUp[i] = 0;
CrossDown[i] = 0;
CrossedUp = false;
CrossedDown = false;
if ( Close[i+1] < MA_ && Close[i] > MA_ ) CrossedUp = true;
if ( Close[i+1] > MA_ && Close[i] < MA_) CrossedDown = true;
if (CrossedUp)
{
if (i == 1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
}
CrossUp[i] = Low[i] - 0.0010;
}
else if (CrossedDown)
{
if (i == 1 && flagval2==0)
{
flagval2=1;
flagval1=0;
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
}
CrossDown[i] = High[i] + 0.0010;
}
}
return(0);
}