Кто-нибудь может подсказать почему при компиляции выдаётся 1 предупреждение ('{' - expression on global scope not allowed) я не специалист , а только пытаюсь что-то переделать под себя.
//+------------------------------------------------------------------+
//| MACD Alert2.mq4 |
//| Trading Team |
//+------------------------------------------------------------------+
#property copyright "Silvio Invernici"
#property link "
http://www.trading-team.it"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Silver
#property indicator_color2 Yellow
#property indicator_color3 Green
#property indicator_color4 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 3
#property indicator_width4 3
extern bool SoundON=true;
extern bool EmailON=false;
extern bool PlaySaundON=true;
extern string Saund1="trendBayEURUSD.wav";
extern string Saund2="trendSellEURUSD.wav";
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalSMA = 9;
extern bool Alerts = false;
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
double HistogramBufferUp[];
double HistogramBufferDown[];
int flagval1 = 0;
int flagval2 = 0;
//---- variables
double Macd_Buffer[];
double Signal_Buffer[];
double Green_Buffer[];
double Red_Buffer[];
int Bars1 = 0;
int Bars2 = 0;
int Bars3 = 0;
int Bars4 = 0;
string IndiName;
//+----------------------init----------------------------------------+
int init() {
IndiName = "MACD Alert2(" + FastEMA + "," + SlowEMA + "," + SignalSMA + ")";
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexStyle(1, DRAW_LINE);
SetIndexDrawBegin(1, SignalSMA);
IndicatorDigits(Digits + 1);
SetIndexBuffer(0, Macd_Buffer);
SetIndexBuffer(1, Signal_Buffer);
SetIndexBuffer(2, Green_Buffer);
SetIndexBuffer(3, Red_Buffer);
IndicatorShortName(IndiName);
SetIndexLabel(0, "MACD");
SetIndexLabel(1, "Signal");
SetIndexLabel(2, "Green");
SetIndexLabel(3, "Red");
return (0);
}
//+----------------------deinit--------------------------------------+
int deinit() {
ObjectDelete("LOGO");
return (0);
}
//+----------------------start---------------------------------------+
int start()
{
if(1==1)logo();
int ind_counted = IndicatorCounted();
if (ind_counted > 0) ind_counted--;
int TotalBars = Bars;
for (int i = 0; i < TotalBars; i++)
{Macd_Buffer
= iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i) - iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);}
for (i = 0; i < TotalBars; i++)
{Signal_Buffer = iMAOnArray(Macd_Buffer, Bars, SignalSMA, 0, MODE_SMA, i);}
for (i = 0; i < TotalBars; i++)
{if (Macd_Buffer > Signal_Buffer)
{Green_Buffer = Macd_Buffer;
Red_Buffer = EMPTY_VALUE;}
else
{Red_Buffer = Macd_Buffer;
Green_Buffer = EMPTY_VALUE;}
}
if (Alerts)
{if (Green_Buffer[1] == Macd_Buffer[1] && Green_Buffer[2] != Macd_Buffer[2]) AlertOnce(Symbol() + " MACD: Long signal!", 0);
if (Red_Buffer[1] == Macd_Buffer[1] && Red_Buffer[2] != Macd_Buffer[2]) AlertOnce(Symbol() + " MACD: Short signal!", 1);
}
return (0);
}
//+----------------------AlertOnce------------------------------------+
void AlertOnce(string Message, int Number) {
switch (Number) {
case 1:
if (Bars1 == 0 || Bars1 < Bars) {
Alert(Message);
Bars1 = Bars;}
break;
case 2:
if (Bars2 == 0 || Bars2 < Bars) {
Alert(Message);
Bars2 = Bars;}
break;
case 3:
if (Bars3 == 0 || Bars3 < Bars) {
Alert(Message);
Bars3 = Bars;}
break;
case 4:
if (Bars4 == 0 || Bars4 < Bars) {
Alert(Message);
Bars4 = Bars;}
break;
}
}
//+----------------------logo----------------------------------------+
void logo()
{
ObjectCreate("LOGO", OBJ_LABEL,WindowFind(IndiName), 0, 0);
ObjectSetText("LOGO", "Revisited by Silvio Invernici", 7, "Arial", DimGray);
ObjectSet("LOGO", OBJPROP_CORNER, 3);
ObjectSet("LOGO", OBJPROP_XDISTANCE, 5);
ObjectSet("LOGO", OBJPROP_YDISTANCE, 3);
}
//+----------------------deinit--------------------------------------+
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
{
int limit;
double temp;
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;
//---- macd counted in the 1-st buffer
for(int i=0; i<limit; i++)
ind_buffer1=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
ind_buffer2=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA, i);
// ind_buffer2 = alpha*ind_buffer1 + alpha_1*ind_buffer2[i+1];
for(i=0; i<limit; i++)
{
HistogramBufferUp = 0;
HistogramBufferDown = 0;
temp = ind_buffer1 - ind_buffer2;
if (temp >= 0)
HistogramBufferUp = temp;
else
HistogramBufferDown = temp;
if (i == 1)
{
if (HistogramBufferUp > 0 && HistogramBufferDown[i + 1] < 0)
// if (HistogramBufferUp > HistogramBufferUp[i + 1])
{
// Cross up
if (flagval1==0)
{
flagval1=1;
flagval2=0;
if (SoundON) Alert("MACD Crossed up","\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\ n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("MACD Crossed up", "MACD Crossed up, Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime() )+" Symbol="+Symbol()+" Period="+Period());
if (PlaySaundON)PlaySound(Saund1);
}
}
else if (HistogramBufferDown < 0 && HistogramBufferUp[i + 1] > 0)
// else if (HistogramBufferUp < HistogramBufferUp[i + 1] )
{
// Cross down
if (flagval2==0)
{
flagval2=1;
flagval1=0;
if (SoundON) Alert("MACD Crossed down","\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\ n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("MACD Crossed down","MACD Crossed Down, Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime() )+" Symbol="+Symbol()+" Period="+Period());
if (PlaySaundON)PlaySound(Saund2);
}
}
}
}
//---- done
return(0);
}
//+----------------------the-end-------------------------------------+