Индикаторы: MTF_atrstops

 

MTF_atrstops:

Индикатор MTF_atrstops. Работает с индикатором ATRStops_v1[1].1.

Author: John Smith

 
О_о
 

единичку кто-то забыл

      ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"ATRStops_v1[1].1",Length,ATRperiod,Kv,1,y);

тогда уж  и лимит

   limit=Bars-counted_bars;
   limit= MathMax(limit,TimeFrame/Period());

а,  черт  - сразу весь:

 

//+------------------------------------------------------------------+
//|                                                 MTF_atrstops.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                             http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

extern int TimeFrame=0;
extern int    Length=10;
extern int    ATRperiod=5;
extern double Kv=2.5;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double smin[];
double smax[];
double trend[];

//--

int init()
  {
   IndicatorBuffers(5);

  
SetIndexStyle(0,DRAW_LINE);
  
SetIndexStyle(1,DRAW_LINE);

  
SetIndexBuffer(0,ExtMapBuffer1);
  
SetIndexBuffer(1,ExtMapBuffer2);
  
SetIndexBuffer(2,smin);
  
SetIndexBuffer(3,smax);
  
SetIndexBuffer(4,trend);


  
SetIndexLabel(0,"Up");
  
SetIndexLabel(1,"Dn");

      SetIndexDrawBegin(0,Length);
  
SetIndexDrawBegin(1,Length);

   switch(TimeFrame)
     {
      case 1 : string TimeFrameStr="Period_M1"; break;
      
case 5 : TimeFrameStr="Period_M5"; break;
      
case 15 : TimeFrameStr="Period_M15"; break;
      
case 30 : TimeFrameStr="Period_M30"; break;
      
case 60 : TimeFrameStr="Period_H1"; break;
      
case 240 : TimeFrameStr="Period_H4"; break;
      
case 1440 : TimeFrameStr="Period_D1"; break;
      
case 10080 : TimeFrameStr="Period_W1"; break;
      
case 43200 : TimeFrameStr="Period_MN1"; break;
      
default : TimeFrameStr="Current Timeframe";
    
}
   IndicatorShortName("MTF_ATRstops("+Length+","+ATRperiod+","+Kv+")["+TimeFrameStr+"]");
  
}

   return(0);
//----

int start()
  {
   datetime TimeArray[];
  
int    i,limit,y=0,counted_bars=IndicatorCounted();

  
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

  
limit=Bars-counted_bars;
  
limit= MathMax(limit,TimeFrame/Period());

  
for(i=0,y=0;i<limit;i++)
     {
      if (Time[i]<TimeArray[y]) y++;

      
ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"ATRStops_v1[1].1",Length,ATRperiod,Kv,0,y);
      
ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"ATRStops_v1[1].1",Length,ATRperiod,Kv,1,y);
  
}
  
    return(0);
 }

 

ну и если уж весь - то и все подряд подчистить

 

//+------------------------------------------------------------------+
//|                                             MTF_ATRstop_v1.1.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//2008fxtsd
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 DeepPink
#property indicator_width1 2
#property indicator_width2 2
extern int TimeFrame=0;
extern int    Length=10;
extern int    ATRperiod=5;
extern double Kv=2.5;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//--
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexDrawBegin(0,Length);
   SetIndexDrawBegin(1,Length);
//---
          TimeFrame = MathMax(TimeFrame,Period());
   switch(TimeFrame)
     {
      case 1: string TimeFrameStr="M1";  break;
      case 5     :   TimeFrameStr="M5";  break;
      case 15    :   TimeFrameStr="M15"; break;
      case 30    :   TimeFrameStr="M30"; break;
      case 60    :   TimeFrameStr="H1";  break;
      case 240   :   TimeFrameStr="H4";  break;
      case 1440  :   TimeFrameStr="D1";  break;
      case 10080 :   TimeFrameStr="W1";  break;
      case 43200 :   TimeFrameStr="MN1"; break;
      default :    TimeFrameStr  ="TF0";
     }
   string short_name;
   short_name="ATRstops ("+Length+","+ATRperiod+","+Kv+") ["+TimeFrameStr+"]";
   IndicatorShortName(short_name);
      SetIndexLabel(0,"Up "+short_name);
      SetIndexLabel(1,"Dn "+short_name);
  }
return(0);
//----
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
   limit=Bars-counted_bars;
   limit= MathMax(limit,TimeFrame/Period());
   for(i=0,y=0;i<limit;i++)
     {
      if (Time[i]<TimeArray[y]) y++;
      ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"ATRStops_v1[1].1",Length,ATRperiod,Kv,0,y);
      ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"ATRStops_v1[1].1",Length,ATRperiod,Kv,1,y);
     }
  
  return(0);
}
//----
Причина обращения: