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

 
Example2:
Hello, if an EA only sets pending orders, should it be able to handle errors?

Yes.

For example.

 
artmedia70:

Yes.

For example.


Would such a function be suitable for error handling?
int ERRORS (int Error)  // Error - номер ошибки  
  {
  if(Error==0)
      return(0);        // Нет ошибки      
  // 4-торговый сервер занят,132-рынок закрыт,137-брокер занят
  if(Error==4||Error==132||Error==137)  
      {
      Sleep(240000);    // Пауза 240 сек.
      return(1);        // Сообщаем о преодол. ошибке
      }
  // 128,142,143 - истек срок ожидания и т.д.
  if(Error==128||Error==142||Error==143) 
      {      
      Sleep(60000);     // Пауза 60 сек.
      return(1);        // Сообщаем о преодол. ошибке 
      }    
  // 135-цена изменилась,138-цена устарела
  if(Error==135||Error==138)               
      {      
      return(1);        // Сообщаем о преодол. ошибке
      }        
  // 6-нет связи,129-неправильные цены,
  // 130-неправильные стопы,136-нет цен
  if(Error==6||Error==129||Error==130||   
  Error==136||Error==137||Error==138)    
      {
      Sleep(5000);      // Пауза 5 сек. 
      return(1);        // Сообщаем о преодол. ошибке
      }
  // 146-подсистема торговли занята
  if(Error==146)               
      {      
      // Пока подсистема занята
      while(IsTradeContextBusy())
         {
         Sleep(10);     // Пауза 0.01 сек.
         }
      return(1);        // Сообщаем о преодол. ошибке
      }         
  // Критическая ошибка
  Alert("Ошибка №",Error,". Дальнейшая работа советника невозможна."); 
  return(2);          // Сообщаем о критич. ошибке
  }
 
Example2:
Would a function like this be suitable for error handling?

Something's too short. Even this one isn't full-fledged either.

//*********************ф-ия обработки ошибок*************************|
int Fun_Error(int Error) 
{
      switch(Error)
   { // Преодолимые ошибки
   case 0: return(1);
   case 4: //Print("Торговый сервер занят. Пробуем ещё раз...");
   Sleep(500); // Простое решение
   return(1); // Выход из функции
   case 128:   //Истек срок ожидания совершения сделки
   return(1);
   case 129: //Print("Цена изменилась. Пробуем ещё раз...");
   return(1); // Выход из функции
   case 132: //Print("Рынок закрыт. Пробуем ещё раз...");
   Sleep(123000); // Это было сделано для робо. У них первые 2 минуты в понедельник рынок закрыт, а надо было ставить ордера в 00:00
   return(1); // Выход из функции
   case 135: //Print("Цена изменилась. Пробуем ещё раз...");
   RefreshRates(); // Обновим данные
   return(1); // Выход из функции
   case 136: //Print("Нет цен. Ждём новый тик...");
   while(RefreshRates()==false) // До нового тика
   Sleep(1); // Задержка в цикле
   return(1); // Выход из функции
   case 137: //Print("Брокер занят. Пробуем ещё раз...");
   Sleep(500); // Простое решение
   return(1); // Выход из функции
   case 138: //Print("Новые цены. Пробуем ещё раз...");
   Sleep(1); // Задержка в цикле
   return(1); // Выход из функции
   case 146: //Print("Подсистема торговли занята. Пробуем ещё...");
   Sleep(500); // Простое решение
   return(1); // Выход из функции
   case 4107: //Print("Неправильный параметр цены для торговой функции. Пробуем ещё...");
   Sleep(50); // Простое решение
   return(1); // Выход из функции
// Критические ошибки
   case 1:
   return(0);
   case 2: Alert("Общая ошибка. Перегрузите терминал и\или компьютер.");
   return(0); // Выход из функции
   case 5: Alert("Старая версия терминала.");
   //Work=false; // Больше не работать
   return(0); // Выход из функции
   case 64: Alert("Счет заблокирован.");
   //Work=false; // Больше не работать
   return(0); // Выход из функции
   case 130: Alert("Неправильные стопы.");
   return(0); // Выход из функции
   case 133: Alert("Торговля запрещена.");
   return(0); // Выход из функции
   case 134: Alert("Недостаточно денег для совершения операции.");
   return(0); // Выход из функции
   case 4051: Alert("Недопустимое значение параметра функции.");
   return(0); // Выход из функции
   case 4108: Alert("Неверный номер тикета.");
   return(0); // Выход из функции
   default: //Print("Возникла ошибка ",Error); // Другие варианты
   return(0); // Выход из функции
   }
}//******************************************************************|

Accordingly, if the function returns 1, we should try to place an order again; if it returns 0, we will exit the function for opening orders.

 
Hi all, anyone using debugging in MT4? In MT5 everything is working here is not going.
 

Citizens, can you tell me why the Alpari terminal is unable to place an order?

The OrderSend function looks like this

ticket_b = OrderSend(Symbol(), OP_BUY, Lot_b, (MarketInfo (Symbol(), MODE_ASK)), 3, ((MarketInfo (Symbol(), MODE_ASK))-SL), ((MarketInfo (Symbol(), MODE_ASK))+TP), "V 5.11 market", Magic, 0, CLR_NONE);

SL = NormalizeDouble (StopLoss * RealPoint,Digits);
TP = NormalizeDouble (TakeProfit * RealPoint,Digits);

Параметры 
Lot_b
Magic

Объявлены и посчитаны ранее.

RealPoint посчитан и равен 0,1

There are no parameters equal to zero. I have checked it.

The minimum stop and profit distance according to the terminal conditions = 0.1.

The terminal generates error 130 and writes about an invalid profit or stop.

SL and TP parameters are 11 and 1 (after normalization), respectively.

On terminals Aforex, Diven FX, ForexClub, AlfaForex - no problems with the same code.

 
fmv_for_a_way:

Citizens, can you tell me why the Alpari terminal is unable to place an order?

The OrderSend function looks like this

There are no parameters equal to zero. I have checked it.

The minimum stop and profit distance according to the terminal conditions = 0.1.

The terminal generates error 130 and writes about an invalid profit or stop.

SL and TP parameters are 11 and 1 (after normalization), respectively.

On terminals Aforex, Diven FX, ForexClub, AlfaForex - no problems with the same code.


buy/sell without stop and takeaway sl=0;tp=0, then modify-->sl=100;tp=300
 
pako:

Buy/sell without stop and takeoff sl=0;tp=0, then modify-->sl=100;tp=300


The thought has already occurred to me out of desperation...

However, the question is why with all the correct parameters the order is not placed.

Since this is a gold chart, the numbers 11 and 1 are quite correct. Translated it means 10 and 110 pips.

I checked prices and stop and profit parameters. There is exactly 120 pips between the profit and stop, and for some reason the opening price = 0.000.

 
2014.05.21 10:35:52.480 '6991883': order buy stop 0.25 XAUUSD opening at 1293.100 sl: 1282.100 tp: 1294.100 failed [Invalid S/L or T/P]

Attempting to place a pending order brought nothing either....

It's getting more and more miraculous.

 

Good day all!

Could you please tell me the best way to code the following condition

If all candlesticks from 1 to 20 are bearish without exception (the number of points between the opening and closing of each candlestick does not matter)

To open an order.

I can't read anything else, just open an order.

 
solnce600:

Good day all!

Could you please tell me the best way to code the following condition

If all candlesticks from 1 to 20 are bearish without exception (the number of points between the opening and closing of each candlestick does not matter)

To open an order.

The only way to do this is to write a "make-work" order.


If I could just write it "by hand".

if(f) OrderSend(...); // открыть ордер Sell


bool f()
{
   for(int i = 1; i <= 20; i++)
    {
     if(Open[i] < Close[i]) return(false);
    }
    return(true);
}