стндартный индикатор МА не полный... - страница 2

 

вот еще попробывал реализовать свою идею таким образом, но она не работает, хотя вроде все правильно:

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Gold

//---- buffers
double Buf_1[], Buf_2[];

int BarsCount = 10000;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    SetIndexStyle(0,DRAW_LINE);
    SetIndexBuffer(0, Buf_1);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(1, Buf_2);   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int i;

    int limit = BarsCount;
    if (limit > Bars)
        limit = Bars;

    for (i = limit; 0 <= i; i--) 
      {
       //----
       double MA_h = iMA(NULL, 0, 5, 0, MODE_SMMA, PRICE_HIGH, i);
       double MA_l = iMA(NULL, 0, 5, 0, MODE_SMMA, PRICE_LOW, i);
       //----
       Buf_1[i] = MA_h;
       Buf_2[i] = MA_l;
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

Вам нужно в отдельном окне именно МА по хай и лоу вывести? Пять минут после ответа "да".

 

да

 
#property indicator_separate_window // в своем окне
#property indicator_buffers 2
#property indicator_color1 Green // MA по хай
#property indicator_color2 Red // по лоу

// входные параметры
extern int MAperiod=5;
extern int MAmethod=0;
// инд. буферы
double MAh[],MAl[];

int init()
  {
   SetIndexBuffer(0,MAh);
   SetIndexStyle(0,DRAW_LINE,0);
   SetIndexLabel(0,"@High");
   
   SetIndexBuffer(1,MAl);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexLabel(1,"@Low");
   
   return(0);
  }

int start()
  {
   int ic=IndicatorCounted();
   int limit=Bars-ic-1; // кол-во пересчетов

   for(int i=limit; i>=0; i--) { 
      MAh[i]=iMA(NULL,0,MAperiod,0,MAmethod,2, i);
      MAl[i]=iMA(NULL,0,MAperiod,0,MAmethod,3, i);
     }
   return(0);
  }
      
 
Svinozavr >>:

спасибо, и правда быстрее чем 5 минут. и понятный код.

 
5 минут - это не на написание кода, а на ваш ответ - код элементарный. Помогло и ладно. Только если вы вдруг решили считать разницы между этими МА, то это уже посчитано и называется ATR.