Вопрос по индикатору SHI_SilverTrendSig.

 
Здравия желаю господа!

Приглянулся мне индюк SHI_SilverTrendSig.mq4, но свои графические сигналы он почему то подаёт только после переключения таймфрейма.
Может чего не хватает в коде или это глюк такой. Я почему то грешу на индикатор.
И ещё если не сложно то может кто посоветует как довавить к нему дополнительное оповещение типа Звук ( различный на Byu и Sell) или ещё лучше в комплекте с информационным окошечком что и где сработало.
Заранее выражаю всем свою благодарность

//+------------------------------------------------------------------+
//|                                           SHI_SilverTrendSig.mq4 |
//|          Copyright © 2003, VIAC.RU, OlegVS, GOODMAN, 2005 Shurka |
//|                                                 shforex@narod.ru |
//|                                                                  |
//|                                                                  |
//| 
//+------------------------------------------------------------------+
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define  SH_BUY   1
#define  SH_SELL  -1
 
//---- Входные параметры
extern int     AllBars=0;//How many bars should be counted. 0 - all the bars.
extern int     Otstup=30;//Step back.
extern double  Per=9;//Period.
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
//+------------------------------------------------------------------+
//| Функция инициализации                                            |
//+------------------------------------------------------------------+
int init()
{
   //We will write the number of the bars for which we are counting to the NB
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,BufU);
   SetIndexBuffer(1,BufD);
   SetIndexDrawBegin(0,Bars-NB);//This indicator will be shown for NB bar only
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);//Give a lot of "zero" to the buffe. Otherwise it will be garbage during the changing of time frame.
   ArrayInitialize(BufU,0.0);
   return(0);
}
//+------------------------------------------------------------------+
//| Функция деинициализации                                          |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Собсна индикатор                                                 |
//+------------------------------------------------------------------+
int start()
{
   int CB=IndicatorCounted();
   /* It is the optimization option. We have the function here which restore/return the number of counted bars in very special way. 
   During the first indicator's call we have 0: it is normal because it was not counted anything, 
   and then we receive the number of bars minus 1. For example, if the number of bars equal 100,
   we will have 99. I did it especially, you may see that NB is the number of bars whioch should be counted. 
   You know we may throw out this parameter. But for the people who understand we may keep it. So, during the first call
   of indicator this NB is the same one but during the 2dn etc calls - reducing the value up to the last bar, 
   That is 1 or 2 for example*/
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for (SH=1;SH<NB;SH++)//comb out the chart from 1 to NB
   {
      for (R=0,i=SH;i<SH+10;i++) {R+=(10+SH-i)*(High[i]-Low[i]);}      R/=55;
 
      SHMax = High[Highest(NULL,0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
      if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) { BufU[SH]=Low[SH]-R*0.5; UD=SH_SELL; }
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY) { BufD[SH]=High[SH]+R*0.5; UD=SH_BUY; }
   }
   return(0);
}
 
Megabait писал (а):

Может чего не хватает в коде или это глюк такой.

Наоборот - избытки мешали.

//+------------------------------------------------------------------+
//|                                           SHI_SilverTrendSig.mq4 |
//|          Copyright © 2003, VIAC.RU, OlegVS, GOODMAN, 2005 Shurka |
//|                                                 shforex@narod.ru |
//|                                                                  |
//|                                                                  |
//| 
//+------------------------------------------------------------------+
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define  SH_BUY   1
#define  SH_SELL  -1
 
//---- Входные параметры
extern int     AllBars=0;//How many bars should be counted. 0 - all the bars.
extern int     Otstup=30;//Step back.
extern double  Per=9;//Period.
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
//+------------------------------------------------------------------+
//| Функция инициализации                                            |
//+------------------------------------------------------------------+
int init()
{
   //We will write the number of the bars for which we are counting to the NB
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);   
   SetIndexBuffer(0,BufU);   
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(1,159);
   SetIndexBuffer(1,BufD);
   return(0);
}
//+------------------------------------------------------------------+
//| Функция деинициализации                                          |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Собсна индикатор                                                 |
//+------------------------------------------------------------------+
int start()
{
   int CB=IndicatorCounted();
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for (SH=1;SH<NB;SH++){
      SHMax = High[Highest(NULL,0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
      if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) {
         BufU[SH]=Low[SH]-iATR(NULL,0,14,SH); UD=SH_SELL; 
      }
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY){
         BufD[SH]=High[SH]+iATR(NULL,0,14,SH); UD=SH_BUY; 
      }
   }
   return(0);
}
 
А вот как он реально выглядит

//+------------------------------------------------------------------+
//|                                           SHI_SilverTrendSig.mq4 |
//|          Copyright © 2003, VIAC.RU, OlegVS, GOODMAN, 2005 Shurka |
//|                                                 shforex@narod.ru |
//|                                                                  |
//|                                                                  |
//| 
//+------------------------------------------------------------------+
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
 
#define  SH_BUY   1
#define  SH_SELL  -1
 
//---- Входные параметры
extern int     AllBars=0;//How many bars should be counted. 0 - all the bars.
extern int     Otstup=30;//Step back.
extern double  Per=9;//Period.
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
//+------------------------------------------------------------------+
//| Функция инициализации                                            |
//+------------------------------------------------------------------+
int init()
{
   //We will write the number of the bars for which we are counting to the NB
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);   
   SetIndexBuffer(0,BufU);   
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(1,159);
   SetIndexBuffer(1,BufD);
   
   return(0);
}
//+------------------------------------------------------------------+
//| Функция деинициализации                                          |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Собсна индикатор                                                 |
//+------------------------------------------------------------------+
int start()
{
   int CB=IndicatorCounted();
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for (SH=NB-1;SH>=0;SH--){
      SHMax = High[Highest(NULL,0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
      if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) {
         BufU[SH]=Low[SH]-iATR(NULL,0,14,SH); UD=SH_SELL; 
      }
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY){
         BufD[SH]=High[SH]+iATR(NULL,0,14,SH); UD=SH_BUY; 
      }
   }
   return(0);
}
 

Inteqer благодарствую за помощь. В понедельник бум тестить :).
А брякалку добавить к нему очень сложно? Чёт сколько я крутил вертел ничего не выходит ......... ума хватает только на то что бы чё нить по мелочи поменять в коде :(.
Где то встречал что через PlaySound ( ) надо, но куда поставить эту функцию ...........
Пробовал по подобию других индюков оповещение добавить ...... . ........ пока безуспешно :)
Вот такая трабла.

 
   }
 
//----------
 
static int lt;
 
if(BufU[1]!=0 && BufU[1]!=EMPTY_VALUE){
   if(lt!=Time[0])Alert("К покупке однако...");
   lt=Time[0];
}
if(BufD[1]!=0 && BufD[1]!=EMPTY_VALUE){
   if(lt!=Time[0])Alert("Однако к продаже...");
   lt=Time[0];
}
 
//----------
 
 
   return(0);
}

Этот индикатор по сути является не сглаженным семидневным стохастиком, точка рисуется если он пересекает уровень 30 сверху вниз (внизу) и 70 снизу вверх (вверху). А из за того, что пересечение смотрится справа на лево, точками отмечается последнее, потому так красиво, но в реале этого не будет.
 
Integer огромные спасибочки за помощь оказанную мне. Ещё было очень интересно узнать принцип действия этого индюка, теперь мне будет намного проще при работе с ним и вообще. Как говорится попутного тренда ВАМ и НАМ .............. если конечно это нужно )))
 
ищется максимум и  минимум за последние N дней - получается канал, канал сужается на Х%, если клоуз вышел за пределы канала ставится точка. Вторая точка в одном направлении не ставится до тех пор пока не появится в другом направлении. Проблема в том, что в оригинале индикатор считается справа на лево и показывается не первая точка выхода за канал а последняя - потому так привлекательно, но в реале этого не будет
 

Подскажите как вытащить значение образования стрелки для того чтобы на следующей свече осуществлять открытие ордера

попробовал вот так вот ...

//+------------------------------------------------------------------+

//|                     Schreibikus_SHI_Silver_Trend_Sig_0902_22.mq4 |

//|                               Copyright © 2009, Roman S Schuklin |

//|                               https://forextd.webasyst.net/shop/ |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2009, Roman S Schuklin"

#property link      "https://forextd.webasyst.net/shop/"


//---- input parameters

extern double    Lots=0.01;          //Объем лота

extern int       SL=0;             //Уровень Stop Loss

extern int       AllBars=0;          //Значения SHI_Silver_Trend_Sig

extern int       Otstup=30;          //Значения SHI_Silver_Trend_Sig

extern double    Per=9.0;            //Значения SHI_Silver_Trend_Sig

extern int       Slippage=3;         //Проскальзывание до 0 - 12

extern int       MAGIC1=32344758;    //Магическое число Sell

extern int       MAGIC2=35782048;    //Магическое число Buy


int ticket,SHI,f,i,start;


int start()

  {

   double iOpen1=NormalizeDouble(iOpen(NULL,0,1),Digits);

   double iClose1=NormalizeDouble(iClose(NULL,0,1),Digits);

   for(f=true,i=2;i<Bars;i++)

   {

      SHI=iCustom(NULL,0,"SHI_SilverTrendSig_1",AllBars,Otstup,Per,0,i);

   }

      double SHI1=NormalizeDouble(SHI*Point,Digits);

      if(OrdersTotal()==0 && iClose1 <= SHI || OrdersTotal()==0 && iClose1 >= SHI)

       {

         Comment(" iClose1 <= SHI1 ", iClose1," <= ",SHI1," ||| ",iClose1," >= ",SHI1);

         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+SL*Point,Bid-25*Point,NULL,MAGIC1,0,Red);

       }else

       

       {

         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-SL*Point,Ask+1000*Point,NULL,MAGIC2,0,Green);

       }

   

//----

   return(0);

  }

//+------------------------------------------------------------------+


Но ничего не получилось

 
Можно чайнику увидеть полный текст, чтобы и сигналы как положено рисовались и алерты уже прикручены были? Сорри...
 

<Integer 17.09.2006 14:11

Megabait писал (а):

Может чего не хватает в коде или это глюк такой.

Наоборот - избытки мешали.>

Взял приведенный текст, сохранил в mq4. Щас точки в другом месте ставит...

Причина обращения: