[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 21

 
forexnew:

Can write zero divide, as far as I remember. But this is due to the fact that certain parameters are not recalculated. In other words, the EA simply does not start correctly because it was started before the work session started.

Of course, these checkboxes have been removed.

If this error occurs(division by zero), the Expert Advisor stops working. Look for a place in the code where division by zero occurs - most likely, zero is obtained as a result of calculation of any parameters.
 
Ay, thank you.
 

Hello dear mql people. Here comes my first code problem.

It is a trend indicator. The task is a trend indicator with coordinates 1-th line = max of last day and the day before and 2-th line = min of last day and the day before.

It would be OK, but when you switch to a lower timeframe, the coordinate is clinging to the beginning of the day, although at the corresponding price level.... and the sense of the line is completely lost.

When creating a trendline object, the datetime parameter is to blame. I cannot think how to get to it. It is necessary to calculate the time of formation of price extrema. It appears that this information

It appears that this information is embedded in the 1-minute timeframe. How to determine the datetime when changing the timeframe so that a trend is re-drawn and coordinates are attached to bars corresponding to extrema.

Unfortunately, the search has yielded nothing on the subject. I would be glad for advice.

 

I need to view the price behaviour over the entire history of the instrument by MA, but the indicator is not drawn when inserted in the chart.

What is the problem ?

When compiled = 0 and 0.

By the way - MT4 terminal hangs !

//--------------------------------------------------------------------
// separatewindow.mq4 
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
#property indicator_chart_window    // Индик. рисуется в основном окне
#property indicator_buffers 1       // Количество буферов
#property indicator_color1 Blue     // Цвет первой линии
#property indicator_color2 Red      // Цвет второй линии

extern int History  =1000000;            // Колич.баров в расчётной истории
extern int Aver_Bars=1000000;             // Количество баров для расчёта

double Buf_0[];                     // Открытие индикаторного массива
//--------------------------------------------------------------------
int init()                          // Специальная функция init()
  {
   SetIndexBuffer(0,Buf_0);         // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Стиль линии
   return;                          // Выход из спец. ф-ии init()
  }
//--------------------------------------------------------------------
int start()                         // Специальная функция start()
  {
   int i,                           // Индекс бара
   n,                               // Формальный параметр
   Counted_bars;                    // Количество просчитанных баров 
   double
   Sum_H,                           // Сумма значений High за переиод
   Sum_L;                           // Сумма значений Low  за переиод
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Количество просчитанных баров 
   i=Bars-Counted_bars-1;           // Индекс первого непосчитанного
   if (i>History-1)                 // Если много баров то ..
      i=History-1;                  // ..рассчитывать заданное колич.
   while(i>=0)                      // Цикл по непосчитанным барам
     {
      Sum_H=0;                      // Обнуление в начале цикла
      Sum_L=0;                      // Обнуление в начале цикла
      for(n=i;n<=i+Aver_Bars-1;n++) // Цикл суммирования значений 
        {
         Sum_H=Sum_H + High[n];     // Накопление суммы макс.значений
         Sum_L=Sum_L + Low[n];      // Накопление суммы мин. значений
        }
      Buf_0[i]=(Sum_H-Sum_L)/Aver_Bars;// Знач. 0 буфера на i-ом баре
      i--;                          // Расчёт индекса следующего бара
     }
//--------------------------------------------------------------------
   return;                          // Выход из спец. ф-ии start()
  }
//--------------------------------------------------------------------
 

I am writing an EA with further transferring stops to Breakeven and increasing Breakeven. Everything seems to work, but there is only one problem. The stop has jumped when the price has moved to Breakeven or Breakeven. I can not fix this problem.

Who knows help plz.

Here is the code:

int poz=OrdersTotal();
for (n=0;n<poz;n++){
            if (OrderSelect(n,SELECT_BY_POS,MODE_TRADES)==true){
            if (OrderType()==OP_BUY){
            Prise2=Bid-OrderOpenPrice();
            if(Prise2>(25*Point)){
            OrderModify(OrderTicket(),0,OrderOpenPrice(),OrderTakeProfit(),0,Blue);}
            if(Prise>Prise3){
            Prise3=(OrderOpenPrice()+(35*Point));
            SL2=OrderOpenPrice()+(10*Point);
            OrderModify(OrderTicket(),0,SL2,OrderTakeProfit(),0,Blue);}}
 
Vodya:

I am writing an EA with further transferring stops to Breakeven and increasing Breakeven. Everything seems to work, but there is only one problem. The stop has jumped when the price has moved to Breakeven or Breakeven. I can not fix this problem.

Who knows help plz.

Here is the code:

Maybe it's the brackets?
 
alex12:
Maybe it's the brackets?

Which ones? If it's after for then it's not the whole part. I just showed the code for buying, but there is also a code for selling.
 

help please, the order should close at 4 times the distance from high to orderopenprice

Where did I mess up?

all orders close within 3 pips of opening

OrderSelect(OrdersTotal()-1,SELECT_BY_POS);
if ((High[0]-OrderOpenPrice())*4<OrderOpenPrice()-Bid&&OrderType()==OP_BUY&&OrdersTotal()>0)
 {
 OrderClose(OrderTicket(),OrderLots(),Bid,3);
 }
 
LazarevDenis:

help please, the order should close at 4 times the distance from high to orderopenprice

Where did I mess up?

here
(High[0]-OrderOpenPrice())*4<OrderOpenPrice()-Bid
 
sergeev:
here


Captain Obviousness... and can someone give me a hint?