Пересечение RVI

 
Здравствуйте!

Помогите пожалуйста, какой код вставить в индикатор, чтобы подавал звуковой сигнал Alert при пересечении в ту или иную сторону?

Можно его как-то ускорить - сделать более чувствительным?

Спасибо.

//+------------------------------------------------------------------+
//|                                          Relativ Vigor Index.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Green
#property  indicator_color2  Red
//---- indicator parameters
extern int ExtRVIPeriod=10;
//---- indicator buffers
double     ExtRVIBuffer[];
double     ExtRVISignalBuffer[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ExtRVIBuffer) && !SetIndexBuffer(1,ExtRVISignalBuffer))
      Print("cannot set indicator buffers!");  
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
//---- drawing settings   
   SetIndexDrawBegin(0,ExtRVIPeriod+3);   
   SetIndexDrawBegin(1,ExtRVIPeriod+7);     
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("RVI("+ExtRVIPeriod+")");
   SetIndexLabel(0,"RVI");
   SetIndexLabel(1,"RVIS");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Relativ Vigor Index                                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,nLimit,nCountedBars;
   double dValueUp,dValueDown,dNum,dDeNum;
//----
   if(Bars<=ExtRVIPeriod+8) return(0);
//----
   nCountedBars=IndicatorCounted();
//---- check for possible errors
   if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted
   nLimit=Bars-ExtRVIPeriod-4;
   if(nCountedBars>ExtRVIPeriod+4)
      nLimit=Bars-nCountedBars;
//---- RVI counted in the 1-st buffer
   for(i=0; i<=nLimit; i++)
      {
        dNum=0.0; 
        dDeNum=0.0;
        for(j=i; j<i+ExtRVIPeriod; j++)
           {
             dValueUp=((Close[j]-Open[j])+2*(Close[j+1]-Open[j+1])+2*(Close[j+2]-Open[j+2])+(Close[j+3]-Open[j+3]))/6;
             dValueDown=((High[j]-Low[j])+2*(High[j+1]-Low[j+1])+2*(High[j+2]-Low[j+2])+(High[j+3]-Low[j+3]))/6;
             dNum+=dValueUp;
             dDeNum+=dValueDown;
           }
        if(!bCompareDouble(dDeNum,0.0))
           ExtRVIBuffer[i]=dNum/dDeNum;
        else
           ExtRVIBuffer[i]=dNum;   
      }
//---- signal line counted in the 2-nd buffer
   nLimit=Bars-ExtRVIPeriod-7;
   if(nCountedBars>ExtRVIPeriod+8)
     nLimit=Bars-nCountedBars+1;
   for(i=0; i<=nLimit; i++)
      ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool bCompareDouble (double dNumber1, double dNumber2)
   {
    bool bCompare=NormalizeDouble(dNumber1 - dNumber2,8) == 0;
    return(bCompare);
   }
 
Здравствуйте!

Помогите пожалуйста, какой код вставить в индикатор, чтобы подавал звуковой сигнал Alert при пересечении в ту или иную сторону?

Можно его как-то ускорить - сделать более чувствительным?

Спасибо.


Вставить
  
 if(ExtRVIBuffer[0]>0 && ExtRVIBuffer[1]<0)
       Alert("Значение RVI(",ExtRVIBuffer[0],")>0");


после строки

ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;
 
[/quote]
Вставить
  
 if(ExtRVIBuffer[0]>0 && ExtRVIBuffer[1]<0)
       Alert("Значение RVI(",ExtRVIBuffer[0],")>0");



после строки

ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;


[/quote]

Не работает! Сигнала нема!

 


Не работает! Сигнала нема!

Пересечение нулевой линии:
//+------------------------------------------------------------------+
//|                               Relativ Vigor Index with Alert.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
// // Индикатор подает сигналы при пересечении нуля главной линий.
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Green
#property  indicator_color2  Red
//---- indicator parameters
extern int ExtRVIPeriod=10;
//---- indicator buffers
double     ExtRVIBuffer[];
double     ExtRVISignalBuffer[];
datetime tCurBarTime=0, tPrevBarTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ExtRVIBuffer) && !SetIndexBuffer(1,ExtRVISignalBuffer))
      Print("cannot set indicator buffers!");  
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
//---- drawing settings   
   SetIndexDrawBegin(0,ExtRVIPeriod+3);   
   SetIndexDrawBegin(1,ExtRVIPeriod+7);     
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("RVI("+ExtRVIPeriod+")");
   SetIndexLabel(0,"RVI");
   SetIndexLabel(1,"RVIS");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Relativ Vigor Index                                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,nLimit,nCountedBars;
   double dValueUp,dValueDown,dNum,dDeNum;
//----
   if(Bars<=ExtRVIPeriod+8) return(0);
//----
   nCountedBars=IndicatorCounted();
//---- check for possible errors
   if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted
   nLimit=Bars-ExtRVIPeriod-4;
   if(nCountedBars>ExtRVIPeriod+4)
      nLimit=Bars-nCountedBars;
//---- RVI counted in the 1-st buffer
   for(i=0; i<=nLimit; i++)
      {
        dNum=0.0; 
        dDeNum=0.0;
        for(j=i; j<i+ExtRVIPeriod; j++)
           {
             dValueUp=((Close[j]-Open[j])+2*(Close[j+1]-Open[j+1])+2*(Close[j+2]-Open[j+2])+(Close[j+3]-Open[j+3]))/6;
             dValueDown=((High[j]-Low[j])+2*(High[j+1]-Low[j+1])+2*(High[j+2]-Low[j+2])+(High[j+3]-Low[j+3]))/6;
             dNum+=dValueUp;
             dDeNum+=dValueDown;
           }
        if(!bCompareDouble(dDeNum,0.0))
           ExtRVIBuffer[i]=dNum/dDeNum;
        else
           ExtRVIBuffer[i]=dNum;   
      }
//---- signal line counted in the 2-nd buffer
   nLimit=Bars-ExtRVIPeriod-7;
   if(nCountedBars>ExtRVIPeriod+8)
     nLimit=Bars-nCountedBars+1;
   for(i=0; i<=nLimit; i++)
      ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;
   if(tCurBarTime==0)
     {
       tCurBarTime=Time[0];
       return(0);
     }
   tPrevBarTime=tCurBarTime;
   tCurBarTime=Time[0];
   if(tPrevBarTime!=tCurBarTime)        
     {
       if(ExtRVIBuffer[1]>=0 && ExtRVIBuffer[2]<=0)
           Alert("RVI(",ExtRVIBuffer[0],") пересек 0 вверх");
       if(ExtRVIBuffer[1]<=0 && ExtRVIBuffer[2]>=0)
           Alert("RVI(",ExtRVIBuffer[0],") пересек 0 вниз");
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool bCompareDouble (double dNumber1, double dNumber2)
   {
    bool bCompare=NormalizeDouble(dNumber1 - dNumber2,8) == 0;
    return(bCompare);
   }
 
Чувствительность регулируется периодом индикатора.
Пересечение линий RVI:
//+------------------------------------------------------------------+
//|                               Relativ Vigor Index with Alert.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
// Индикатор подает сигналы при пересечении главной и сигнальной линий.
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Green
#property  indicator_color2  Red
//---- indicator parameters
extern int ExtRVIPeriod=10;
//---- indicator buffers
double     ExtRVIBuffer[];
double     ExtRVISignalBuffer[];
datetime tCurBarTime=0, tPrevBarTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ExtRVIBuffer) && !SetIndexBuffer(1,ExtRVISignalBuffer))
      Print("cannot set indicator buffers!");  
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
//---- drawing settings   
   SetIndexDrawBegin(0,ExtRVIPeriod+3);   
   SetIndexDrawBegin(1,ExtRVIPeriod+7);     
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("RVI("+ExtRVIPeriod+")");
   SetIndexLabel(0,"RVI");
   SetIndexLabel(1,"RVIS");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Relativ Vigor Index                                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,nLimit,nCountedBars;
   double dValueUp,dValueDown,dNum,dDeNum;
//----
   if(Bars<=ExtRVIPeriod+8) return(0);
//----
   nCountedBars=IndicatorCounted();
//---- check for possible errors
   if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted
   nLimit=Bars-ExtRVIPeriod-4;
   if(nCountedBars>ExtRVIPeriod+4)
      nLimit=Bars-nCountedBars;
//---- RVI counted in the 1-st buffer
   for(i=0; i<=nLimit; i++)
      {
        dNum=0.0; 
        dDeNum=0.0;
        for(j=i; j<i+ExtRVIPeriod; j++)
           {
             dValueUp=((Close[j]-Open[j])+2*(Close[j+1]-Open[j+1])+2*(Close[j+2]-Open[j+2])+(Close[j+3]-Open[j+3]))/6;
             dValueDown=((High[j]-Low[j])+2*(High[j+1]-Low[j+1])+2*(High[j+2]-Low[j+2])+(High[j+3]-Low[j+3]))/6;
             dNum+=dValueUp;
             dDeNum+=dValueDown;
           }
        if(!bCompareDouble(dDeNum,0.0))
           ExtRVIBuffer[i]=dNum/dDeNum;
        else
           ExtRVIBuffer[i]=dNum;   
      }
//---- signal line counted in the 2-nd buffer
   nLimit=Bars-ExtRVIPeriod-7;
   if(nCountedBars>ExtRVIPeriod+8)
     nLimit=Bars-nCountedBars+1;
   for(i=0; i<=nLimit; i++)
      ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;
   if(tCurBarTime==0)
     {
       tCurBarTime=Time[0];
       return(0);
     }
   tPrevBarTime=tCurBarTime;
   tCurBarTime=Time[0];
   if(tPrevBarTime!=tCurBarTime)        
     {
       if(ExtRVIBuffer[2]>=ExtRVISignalBuffer[2] && ExtRVIBuffer[1]<=ExtRVISignalBuffer[1])
           Alert("Линии RVI пересеклись вниз");
       if(ExtRVIBuffer[2]<=ExtRVISignalBuffer[2] && ExtRVIBuffer[1]>=ExtRVISignalBuffer[1])
           Alert("Линии RVI пересеклись вверх");
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool bCompareDouble (double dNumber1, double dNumber2)
   {
    bool bCompare=NormalizeDouble(dNumber1 - dNumber2,8) == 0;
    return(bCompare);
   }
 
Спасибо Marat, но я имел ввиду не пересечение нулевой линии, перечечение самих линий.

Все уже решено - хороший человек помог!
 
Перестал приходить отчет на e-mail о том, что поступил ответ по данной теме!
Причина обращения: