Omukchaan
Элитный участник
Не отключается алерт, если "False" - как побороть ?
Или кто-нибудь поправит, еще лучше будет.
Привет!
Ограничение поставил вместе со звуком.
Скопируй код там.
Код:
//+------------------------------------------------------------------+
//| ADX Crossing.mq4 |
//| Amir |
//| modified by Ctmcn |
//+------------------------------------------------------------------+
#property copyright "Author - Amir"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LightSkyBlue
#property indicator_color2 OrangeRed
//---- input parameters
extern int ADXbars=14;
extern int CountBars=350;
extern string SoundFile="Alert.wav";
extern bool UseSound_Alert=False;
bool SoundBuy = False;
bool SoundSell = False;
//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2 |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
int i,shift,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=CountBars;i++) val1[CountBars-i]=0.0;
for(i=1;i<=CountBars;i++) val2[CountBars-i]=0.0;
}
for (shift = CountBars; shift>=0; shift--)
{
b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift-1);
nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift);
b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift-1);
nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift);
if (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
{
val1[shift]=Low[shift]-5*Point;
}
if (val1[1] != EMPTY_VALUE && val1[1] != 0 && SoundBuy)
{
SoundBuy = False;
if (UseSound_Alert) PlaySound (SoundFile);
if (UseSound_Alert) Alert("BUY - "+_Symbol+ " " + "- "+TimeFrameToString(_Period));
}
if (!SoundBuy && (val1[1] == EMPTY_VALUE || val1[1] == 0)) SoundBuy = True;
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi)
{
val2[shift]=High[shift]+5*Point;
}
if (val2[1] != EMPTY_VALUE && val2[1] != 0 && SoundSell)
{
SoundSell = False;
if (UseSound_Alert) PlaySound (SoundFile);
if (UseSound_Alert) Alert("SELL - "+_Symbol+ " " + "- "+TimeFrameToString(_Period));
}
if (!SoundSell && (val2[1] == EMPTY_VALUE || val2[1] == 0)) SoundSell = True;
}
return(0);
}
string TimeFrameToString(int tf)
{
string tfs;
switch(tf)
{
case PERIOD_M1:
tfs = "M1" ;
break;
case PERIOD_M5:
tfs = "M5" ;
break;
case PERIOD_M15:
tfs = "M15" ;
break;
case PERIOD_M30:
tfs = "M30" ;
break;
case PERIOD_H1:
tfs = "H1" ;
break;
case PERIOD_H4:
tfs = "H4" ;
break;
case PERIOD_D1:
tfs = "D1" ;
break;
case PERIOD_W1:
tfs = "W1" ;
break;
case PERIOD_MN1:
tfs = "MN";
}
return(tfs);
}
//+------------------------------------------------------------------+
Последнее редактирование модератором: