Может кто поможет поправить алерт в индикаторе

 

Ja noviciok v etom dele,poprpbuval vstavit alert v trendenvelop,on zvucit na kazdom tike,kak popravit cifri,cto on zazvucel tolka kak dvinetsa..

S uvazenijem ...

-------------------------------------------------------------------------

//+------------------------------------------------------------------+
//| TrendEnvelopes_v1.mq4 |
//| Copyright © 2006, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 LightBlue
#property indicator_color2 Orange
#property indicator_width1 3
#property indicator_width2 3
#property indicator_color3 LightBlue
#property indicator_color4 Orange
#property indicator_width3 3
#property indicator_width4 3
//---- indicator parameters
extern int MA_Period =14;
extern int MA_Shift =0;
extern int MA_Method =3;
extern int Applied_Price=0;
extern double Deviation =0.2;
extern int UseSignal =0;
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
double UpSignal[];
double DnSignal[];
double smax[];
double smin[];
double trend[];
#define SIGNAL_BAR 0

//----

int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE);
SetIndexShift(0,MA_Shift);
SetIndexStyle(1,DRAW_LINE);
SetIndexShift(1,MA_Shift);
//
SetIndexStyle(2,DRAW_ARROW);
SetIndexShift(2,MA_Shift);
SetIndexArrow(2,233);
SetIndexStyle(3,DRAW_ARROW);
SetIndexShift(3,MA_Shift);
SetIndexArrow(3,234);
//
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=14;
draw_begin=MA_Period-1;
//---- indicator short name
IndicatorShortName("Env("+MA_Period+")");
SetIndexLabel(0,"UpTrendEnv");
SetIndexLabel(1,"DnTrendEnv");
SetIndexLabel(2,"UpSignal");
SetIndexLabel(3,"DnSignal");
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
SetIndexDrawBegin(2,draw_begin);
SetIndexDrawBegin(3,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,UpSignal);
SetIndexBuffer(3,DnSignal);
SetIndexBuffer(4,smax);
SetIndexBuffer(5,smin);
SetIndexBuffer(6,trend);
if(Deviation<0.1) Deviation=0.1;
if(Deviation>100.0) Deviation=100.0;
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
limit=Bars-ExtCountedBars;
//---- EnvelopesM counted in the buffers
for(int i=limit; i>=0; i--)
{
smax[i]=(1+Deviation/100)*iMA(NULL,0,MA_Period,0,MA_Method,Applied_Price,i);
smin[i]=(1-Deviation/100)*iMA(NULL,0,MA_Period,0,MA_Method,Applied_Price,i);
trend[i]=trend[i+1];
if (Close[i]>smax[i+1]) trend[i]=1;
if (Close[i]<smin[i+1]) trend[i]=-1;
if(trend[i]>0)
{
if (smin[i]<smin[i+1]) smin[i]=smin[i+1];
UpBuffer[i]=smin[i];
if (UseSignal>0)
if (trend[i+1]<0) UpSignal[i]=Low[i]-0.5*iATR(NULL,0,MA_Period,i);
DnBuffer[i]=EMPTY_VALUE;
}
else
{
if(smax[i]>smax[i+1]) smax[i]=smax[i+1];
DnBuffer[i]=smax[i];
if (UseSignal>0)
if (trend[i+1]>0) DnSignal[i]=High[i]+0.5*iATR(NULL,0,MA_Period,i);
UpBuffer[i]=EMPTY_VALUE;
}
}
//---- Статические переменные, в которых хранятся
//---- время последнего бара и направление последнего сигнала
static int PrevSignal = 0, PrevTime = 0;

//---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал
//---- несколько раз. Если не начался новый бар, выходим.
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime )
return(0);
//---- Отмечаем, что этот бар проверен
PrevTime = Time[0];
if(PrevSignal <= 0 )
{
if(DnBuffer[SIGNAL_BAR] > 1)
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Doun!!!");
}
}
if(PrevSignal >= 0)
{
if(UpBuffer[SIGNAL_BAR] > -1)
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Up!!!");
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+

 

cto on zazvucel tolka kak dvinetsa.



Кто куда двинется?

Поясните конкретнее

 
Spasiba cto

xotite pomoc po moemu voprosu..

Est dve liniji trend v niz i trend v verx,kogda Flet ona idiot ploska i priama,kogda nacinaetsa trend sinija idiot verx,a koricnevaja v niz.Mne nado kogda nacinaet xod sto zazvonel alert..

S poctenijem..

 
psilaju grafik
 
//---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал
//---- несколько раз. Если не начался новый бар, выходим.
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime )
return(0);
//---- Отмечаем, что этот бар проверен
PrevTime = Time[0];
if(PrevSignal <= 0 )
{
if( (DnBuffer[SIGNAL_BAR] < DnBuffer[SIGNAL_BAR+1] && DnBuffer[SIGNAL_BAR+1]==DnBuffer[SIGNAL_BAR+2]) || (DnBuffer[SIGNAL_BAR]>0 && DnBuffer[SIGNAL_BAR+1]==0) )
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Doun!!!");
}
}
if(PrevSignal >= 0)
{
if ( (UpBuffer[SIGNAL_BAR] > UpBuffer[SIGNAL_BAR+1] &&  UpBuffer[SIGNAL_BAR+1]==UpBuffer[SIGNAL_BAR+2] ) || (UpBuffer[SIGNAL_BAR]>0 && UpBuffer[SIGNAL_BAR+1]==0) )
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Up!!!");
}
}
//---- done
Попробуйте так. Сам проверить работоспособность не могу-нет времени.
 
Bolsoje spasibo...poprobuju..
 
Nekak nerabotaet..mne kak novicku tut tiomnij les...
 

Parabotal escio s nim,kompiliroval...osibok netu...varnings toze..

//+------------------------------------------------------------------+
//| TrendEnvelopes_v1.mq4 |
//| Copyright © 2006, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 LightBlue
#property indicator_color2 Orange
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color3 LightBlue
#property indicator_color4 Orange
#property indicator_width3 2
#property indicator_width4 2
//---- indicator parameters
extern int MA_Period =14;
extern int MA_Shift =0;
extern int MA_Method =3;
extern int Applied_Price=0;
extern double Deviation =0.2;
extern int UseSignal =0;
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
double UpSignal[];
double DnSignal[];
double smax[];
double smin[];
double trend[];
#define SIGNAL_BAR 1
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE);
SetIndexShift(0,MA_Shift);
SetIndexStyle(1,DRAW_LINE);
SetIndexShift(1,MA_Shift);
//
SetIndexStyle(2,DRAW_ARROW);
SetIndexShift(2,MA_Shift);
SetIndexArrow(2,233);
SetIndexStyle(3,DRAW_ARROW);
SetIndexShift(3,MA_Shift);
SetIndexArrow(3,234);
//
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=14;
draw_begin=MA_Period-1;
//---- indicator short name
IndicatorShortName("Env("+MA_Period+")");
SetIndexLabel(0,"UpTrendEnv");
SetIndexLabel(1,"DnTrendEnv");
SetIndexLabel(2,"UpSignal");
SetIndexLabel(3,"DnSignal");
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
SetIndexDrawBegin(2,draw_begin);
SetIndexDrawBegin(3,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,UpSignal);
SetIndexBuffer(3,DnSignal);
SetIndexBuffer(4,smax);
SetIndexBuffer(5,smin);
SetIndexBuffer(6,trend);
if(Deviation<0.1) Deviation=0.1;
if(Deviation>100.0) Deviation=100.0;
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
limit=Bars-ExtCountedBars;
//---- EnvelopesM counted in the buffers
for(int i=limit; i>=0; i--)
{
smax[i]=(1+Deviation/100)*iMA(NULL,0,MA_Period,0,MA_Method,Applied_Price,i);
smin[i]=(1-Deviation/100)*iMA(NULL,0,MA_Period,0,MA_Method,Applied_Price,i);
trend[i]=trend[i+1];
if (Close[i]>smax[i+1]) trend[i]=1;
if (Close[i]<smin[i+1]) trend[i]=-1;
if(trend[i]>0)
{
if (smin[i]<smin[i+1]) smin[i]=smin[i+1];
UpBuffer[i]=smin[i];
if (UseSignal>0)
if (trend[i+1]<0) UpSignal[i]=Low[i]-0.5*iATR(NULL,0,MA_Period,i);
DnBuffer[i]=EMPTY_VALUE;
}
else
{
if(smax[i]>smax[i+1]) smax[i]=smax[i+1];
DnBuffer[i]=smax[i];
if (UseSignal>0)
if (trend[i+1]>0) DnSignal[i]=High[i]+0.5*iATR(NULL,0,MA_Period,i);
UpBuffer[i]=EMPTY_VALUE;
}
}
//+------------------------------------------------------------------+
//---- Статические переменные, в которых хранятся
//---- время последнего бара и направление последнего сигнала
static int PrevSignal = 0, PrevTime = 0;

//---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал
//---- несколько раз. Если не начался новый бар, выходим.
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime )
return(0);
//---- Отмечаем, что этот бар проверен
PrevTime = Time[0];
if(PrevSignal <= 0 )
{
if( (DnBuffer[SIGNAL_BAR] < DnBuffer[SIGNAL_BAR+1] && DnBuffer[SIGNAL_BAR+1]==DnBuffer[SIGNAL_BAR+2]) || (DnBuffer[SIGNAL_BAR]>0 && DnBuffer[SIGNAL_BAR+1]==0) )
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Doun!!!");
}
}
if(PrevSignal >= 0)
{
if ( (UpBuffer[SIGNAL_BAR] > UpBuffer[SIGNAL_BAR+1] && UpBuffer[SIGNAL_BAR+1]==UpBuffer[SIGNAL_BAR+2] ) || (UpBuffer[SIGNAL_BAR]>0 && UpBuffer[SIGNAL_BAR+1]==0) )
{
PrevSignal = 0;
Alert("trend (", Symbol(), ", ", Period(), ") - Up!!!");
}
}
//---- done
//---- done
return(0);
}

 
Osibok netu...varnings toze..,Alert nerabotaet.Mozet kto ponimaet kak popravit,budet ocen bolsoje spasibo.
 
arnas77:
Osibok netu...varnings toze..,Alert nerabotaet.Mozet kto ponimaet kak popravit,budet ocen bolsoje spasibo.

А на сколько большое спасибо?

Немного исправил. Проверил, работает. Но не знаю так или не так.

Файлы:
 

вставьте такой код....

//---- Статические переменные, в которых хранятся
//---- время последнего бара и направление последнего сигнала
static int PrevSignal = 0, PrevTime = 0;
//---- Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал
//---- несколько раз. Если не начался новый бар, выходим.
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime ) 
return(0);
//---- Отмечаем, что этот бар проверен
PrevTime = Time[0];
if(PrevSignal >= 0 )
{
if(DnBuffer[SIGNAL_BAR] < DnBuffer[SIGNAL_BAR+1])
{
PrevSignal = -1;
Alert("trend (", Symbol(), ", ", Period(), ") - Doun!!!");
}
}
if(PrevSignal <= 0)
{
if(UpBuffer[SIGNAL_BAR] > UpBuffer[SIGNAL_BAR+1] )
{
PrevSignal = 1;
Alert("trend (", Symbol(), ", ", Period(), ") - Up!!!");
}
}
Терь вроде работает
Причина обращения: