Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 697

 
evillive:

not only can you do it, you have to.
Well, it will be limited to the objects of all sub-windows of the main chart window selected in chart_id.
 

Dear programmers, I have received this warning, what changes should I enter in the EA settings or what does it mean? (I have erased the broker's name for obvious reasons):

Dear Client!


We would like to inform you that,
due to the planned technological infrastructure and modernization of EQUIPMENT, connections to data centres .............-Live 3 from the IP-address............... will be terminated on Saturday 30 August 2014 your trading terminals will be automatically connected to one of the two data centres at the following addresses:

dc1.mt4..........com:443 (USA)
dc2.mt4..........com:443 (Germany).


Please make appropriate changes in the trading advisors settings, if necessary.

 

Hello!

How do I calculate the 20-bar maximum and minimum values for each bar and impose them on the line?

#property indicator_chart_window              //Свойство:индикатор рисуется в основном окне
#property indicator_buffers 2                 // Количество буферов
#property indicator_plots   2                 // Кол-во графиков
//--- График  Max цены за период
#property indicator_label1  "Max"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- График Min цены за период
#property indicator_label2  "Min"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- Объявление массивов
double         MaxBuffer[];
double         MinBuffer[];

extern int Quant_Bars=20;                       //Количество баров
                                                //Переменные для горизонтальной линии по максимуму и мин

int pos; 
   double dMaximum;                          // Максимальная цена
   double dMinimum;       
//+------------------------------------------------------------------+
//| Специальная функция OnInit                     |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Отображение данных из буфера
   SetIndexBuffer(0,MaxBuffer);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,MinBuffer);
   SetIndexStyle(1,DRAW_LINE);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int counted_bars=IndicatorCounted(); // переменная для хранения кол-ва баров
//---- Проверка есть,ли ошибки
   if(counted_bars<0) return(-1);

//---- Доп проверка учета неучтенных баров
 if(counted_bars>0) counted_bars--;

   pos = Bars-counted_bars;

//---- Основной расчетный цикл
   while(pos>=0)
     { 
                           // Текущая минималная цена
      dMinimum = GetMinPrice();
      dMaximum = GetMaxPrice();
   
      MaxBuffer[pos] = dMaximum;
      MinBuffer[pos] = dMinimum;
      pos--;
     }

   Comment("Кол-во баров ",Bars,"Кол-во непосчитанных свечей\n"
   ,pos,dMinimum,dMaximum);

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

//--------------------Функция минимальной цены за выбранный промежуток времени-----------------

double GetMinPrice()
  {
      double dLow= 1000000;                        // Минимальный уровень
      double dPriceLow; 
   for(int i=1;i<= Quant_Bars;i++) // От 1 (!) до..
     {
      dPriceLow=iLow(Symbol(),0,i);          // узнаем текущую минимальную цену i-бара
      if(dPriceLow<dLow)                     // Если текущий Low бара < известного dLow
         dLow=dPriceLow;                     // то оно и будет минимумом

     }
   return(dLow);
  }
//--------------------Функция минимальной цены за выбранный промежуток времени-----------------

double GetMaxPrice()
  {
   double dHigh=0;                        // Цена макс уровня
   double dPriceHigh;                     // Текущая максимальная цена i-бара
   for(int i=1;i<=Quant_Bars;i++)         // От 1 (!) до..
     {
      dPriceHigh=iHigh(Symbol(),0,i);     // узнаем текущую максимальную цену i-бара
      if(dPriceHigh>dHigh)                // Если текущий Low бара < известного dLow
         dHigh=dPriceHigh;                       // то оно и будет минимумом

     }
   return(dHigh);
  }

I can only use it for the 0th bar.

 
AndrianoS:

Hello!

How do I calculate the 20-bar maximum and minimum values for each bar and impose them on the line?

I can only use it for the 0-th bar.

I would like to know why you don't like them. :

//+------------------------------------------------------------------+
double GetMinPrice(string sy, int timeframe, int count=WHOLE_ARRAY, int begin=0) {
   return(iLow(sy,timeframe,iLowest(sy,timeframe,MODE_LOW,count,begin)));
   }
//+------------------------------------------------------------------+
double GetMaxPrice(string sy, int timeframe, int count=WHOLE_ARRAY, int begin=0) {
   return(iHigh(sy,timeframe,iHighest(sy,timeframe,MODE_HIGH,count,begin)));
   }
//+------------------------------------------------------------------+

I haven't looked any further...

Here's this: "...for each bar the value of the 20-bar high and low..." - is not clear at all.

 
AndrianoS:

Hello!

How do I calculate the 20-bar maximum and minimum values for each bar and impose them on the line?

I can only use it for the 0th bar.

Everything is much simpler. I tried doing different channel indicators once too. Here is the code

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Aqua
//--- input parameters
extern int       min=20;
extern int       max=20;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   IndicatorDigits(Digits+1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int counted_bars=IndicatorCounted(),                      
    limit;
    double minimum,maximum;
   if(counted_bars>0)
      counted_bars--;  
   limit=Bars-counted_bars;
   for(int i=0;i<limit;i++)
   {
      minimum=Low[iLowest(NULL,0,MODE_LOW,min,i)];
      maximum=High[iHighest(NULL,0,MODE_HIGH,max,i)];
      ExtMapBuffer1[i]=minimum;
      ExtMapBuffer2[i]=maximum;
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
Forexman77:

It's a lot simpler than that. I tried making various channel indicators once too. Here's the code


Thanks to everyone who responded. I will learn more.
 
What helps you better with a simple moving average or an exponential one, if it doesn't help at all why do you use it?
 

People, tell me how to display the period setting for the indicator. I tried it this way, it doesn't work:

extern string Per= H1;

double prodaem1=iCustom(Symbol(),PERIOD_ Per, "super-signals-channel",2,500,2,sdvig);

 
woin2110:

People, tell me how to display the period setting for the indicator. I tried it this way, it doesn't work:

extern string Per= H1;

double prodaem1=iCustom(Symbol(),PERIOD_ Per, "super-signals-channel",2,500,2,sdvig);


You can do this: extern int Per= 60; //string H1;

double prodaem1=iCustom(Symbol(),Per, "super-signals-channel",2,500,2,sdvig); //PERIOD_

In fact, see Documentation!

 
borilunad:

You can do it this way: extern string Per= 60; //H1;

double prodaem1=iCustom(Symbol(),Per, "super-signals-channel",2,500,2,sdvig); //PERIOD_

In fact, see Documentation!


You cannot do it this way either.


Period is of the int type.

Reason: