iEnvelopesOnArray всегда дает 0 - страница 2

 

даже при таком коде:

   for(i=0; i<100+ENVma_period; i++)
     {

      ssld_temp[i]=ssld[i];
     }
   ArraySetAsSeries(ssld_temp,true);

   for(i=0; i<100; i++)
     {

      double val1=iEnvelopesOnArray(ssld_temp,100+ENVma_period,ENVma_period,MODE_SMA,ENVma_period,ENVdeviation,MODE_UPPER,i);
      envelopes[i]=val1;
      Print("val1="+val1+"  ArraySize ="+ArraySize(ssld_temp)+"i="+i+" ssld_temp="+ssld_temp[i]+" ssld="+ssld[i]+" envelopes="+envelopes[i]);
     }

 только на 0 баре рассчитывает значения, а остальное = 0

val1=0  ArraySize =103i=2 ssld_temp=0.7482 ssld=0.7482 envelopes=0

val1=0  ArraySize =103i=1 ssld_temp=0.74819 ssld=0.74819 envelopes=0

val1=0.74841  ArraySize =103i=0 ssld_temp=0.7483 ssld=0.7483 envelopes=0.74841


 

банальный код


с Ма работает а с Envelopes- нет

 

Код взят StockProgrammer@mail.ru
#property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 DarkBlue double ExtMapBuffer1[]; double ExtMapBuffer2[]; int init() {   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));   SetIndexStyle(0,DRAW_LINE);   SetIndexBuffer(0,ExtMapBuffer1);   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);   SetIndexBuffer(1,ExtMapBuffer2);      return(0); } int deinit() {   return(0); }    int start() {   int bar, limit;      int counted_bars=IndicatorCounted();   if(counted_bars<0) return(-1);   if(counted_bars>0) counted_bars--;   limit=Bars-IndicatorCounted();           for(bar=0; bar<limit; bar++)       ExtMapBuffer1[bar] = iCCI(NULL,0,14,PRICE_TYPICAL,bar);      for(bar=0; bar<limit; bar++)      // ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,14,0,MODE_EMA,bar);       ExtMapBuffer2[bar]= iEnvelopesOnArray(ExtMapBuffer1,Bars,3,MODE_SMA,0,0.05,MODE_UPPER,bar);      return(0); }
 

с болингером также работает 

Код взят StockProgrammer@mail.ru


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DarkBlue

double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
{
  IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
  SetIndexStyle(0,DRAW_LINE);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
  SetIndexBuffer(1,ExtMapBuffer2);
  
  return(0);
}

int deinit()
{
  return(0);
}
  
int start()
{
  int bar, limit;
  
  int counted_bars=IndicatorCounted();
  if(counted_bars<0) return(-1);
  if(counted_bars>0) counted_bars--;
  limit=Bars-IndicatorCounted();
    
  
  for(bar=0; bar<limit; bar++)
      ExtMapBuffer1[bar] = iCCI(NULL,0,14,PRICE_TYPICAL,bar);
  
  for(bar=0; bar<limit; bar++)
     // ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,14,0,MODE_EMA,bar);
      //ExtMapBuffer2[bar]= iEnvelopesOnArray(ExtMapBuffer1,Bars,3,MODE_EMA,0,0.05,1,bar);
      ExtMapBuffer2[bar]= iBandsOnArray(ExtMapBuffer1,Bars,3,0,0,0,bar);
  
  return(0);
}
 

а вот так заработал с Envelopes

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DarkBlue

double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
{
  IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
  SetIndexStyle(0,DRAW_LINE);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
  SetIndexBuffer(1,ExtMapBuffer2);
  
  return(0);
}

int deinit()
{
  return(0);
}
  
int start()
{
  int bar, limit;
  
  int counted_bars=IndicatorCounted();
  if(counted_bars<0) return(-1);
  if(counted_bars>0) counted_bars--;
  limit=Bars-IndicatorCounted();
    
  
  for(bar=0; bar<limit; bar++)
      ExtMapBuffer1[bar] = iCCI(NULL,0,14,PRICE_TYPICAL,bar);
  
  
    int MA_Period=3;
   for(int i=0; i<limit; i++)
     { 
      ExtMapBuffer2[i] = (1+0.05/100)*iMAOnArray(ExtMapBuffer1,Bars,MA_Period,0,MODE_SMA,i);
     }

  return(0);
}

 

 

 

 

проблема решена, вместо iEnvelopesonArray - использовать  (1+0.05/100)*iMAOnArray(ExtMapBuffer1,Bars,MA_Period,0,MODE_SMA,i);

prodigy рулит.... 

 

просьба модераторам - я сам часто юзаю поиск. Если у кого то возникнет проблема, плиз мой последний пост перенести в шапку. 

 
А как получить Access violation read to 0x09986000 ?
 

А как получить Access violation read to 0x09986000 ? 

хм, вопрос хороший.  

использовать iEnvelopesOnArray 

у меня после 3  записи - вылетает такая ошибка. 

 

пример так приводит к критической ошибке:

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DarkBlue

double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
{
  IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
  SetIndexStyle(0,DRAW_LINE);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
  SetIndexBuffer(1,ExtMapBuffer2);
  
  return(0);
}

int deinit()
{
  return(0);
}
  
int start()
{
  int bar, limit;
  
  int counted_bars=IndicatorCounted();
  if(counted_bars<0) return(-1);
  if(counted_bars>0) counted_bars--;
  limit=Bars-IndicatorCounted();
    
  
  for(bar=0; bar<limit; bar++)
      ExtMapBuffer1[bar] = iCCI(NULL,0,14,PRICE_TYPICAL,bar);
  
  for(bar=0; bar<limit; bar++)
     // ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,14,0,MODE_EMA,bar);
      ExtMapBuffer2[bar]= iEnvelopesOnArray(ExtMapBuffer1,Bars,3,MODE_SMA,0,0.05,MODE_UPPER,bar);
  
  return(0);
}
 
Спасибо
Причина обращения: