Beta version of the online book on MQL4 programming - by Sergey Kovalev (SK.) - page 7

 

I would also wonder why the text uses functions without brackets OrderType() OrderOpenPrice()

 
Climber:
// Критерии закрытия ордеров

if
(_OrdersTotal == 1) //Выполнять следующее если открыт 1 ордер
{
OrderSelect(0, SELECT_BY_POS);
Tip = OrderType;
OPrice = OrderOpenPrice;

if (Tip = 0) // Расчитать цену закрытия в зависимости от типа ордера (В=0,S=1)
{
Cprice = OPrice + (TakeProfit*Point) + Spread;
if (Bid >= Cprice)
{
Cls_B = True;
}
}
if (Tip = 1)                 
{
Cprice = OPrice - (TakeProfit*Point) - Spread;
if (Ask <= Cprice)
{
Cls_S = True;
}
}
In your code, it is not the lack of brackets that is wrong, but other errors, such as missing another equal sign in the condition (marked in red)
 
Didn't help ==. Still the same bracket is written in the errors. Can the close criterion not be written in the code, if take profit is set? Or it may not work, for example, if the price is suddenly close to TP and suddenly it changes by several points in one tick, jumping over the TP?
 
Climber:
Or could it fail, for example, if the price suddenly approaches the TP and suddenly changes by several pips in one tick, jumping over the TP?


This is theoretically possible. That is, the order will still be closed, but it may be closed not at the TP price, but at the first price that appears.
I think you may be interested in reading the MQL4 Tutorial - Trade Operations - Order Parameters and Trading Operations Rules. It deals with a similar example with slippage.

 
Another original feature at the stage of learning programming - all the time to put a comma I press the letter b, where there is a comma in the English layout))). It turns out that you write in Russian, but when you put a comma you forget that the Russian layout.
 
Climber:
Another original feature at the stage of learning programming - all the time to put a comma I press the letter b, where there is a comma in the English layout))). It turns out that you write in Russian, but when you put a comma you forget that the Russian layout.

That's why many people write software in English, without using Russian, it's faster and easier, the layout doesn't change that often, and then the program is adapted to Russian for someone else, if comments are required, just in this period of work, it's most convenient to russify, for some reason:) English layout is the basis for people who are engaged in such writing, the Russian is used at a very minimal scale, if you estimate % usage of English layout, it's 99% of the time. I used to want to write programs in Russian, but after having fun with 1C this desire has evaporated.
 
Rosh:
The problem is found out, we will fix it.

Now I can see the drawings at https://book.mql4.com/ru/metaeditor/compose
 

I wonder how you got my messages to disappear. It's not a fair discussion, guys. If you have nothing to say, say so. I understand.

 

I only hope that those to whom I wrote have read and responded

 
Found the functions I need on the forum. One returns the bar number of the ZigZag extremum by its bar number and the second one returns the ZigZag extremum by its bar number. The first one will help me determine whether a new extremum of the ZigZag has emerged (if the bar number of the zero ZigZag = 0) and proceed from there to check other criteria. The second one will also be useful. But it is too early for the second one. I would like to handle the first one.

I have implemented this function in the editor and created an indicator. I did not add or subtract anything. But during compilation, I got so many errors. They are horrible. Then I tried to create an Expert Advisor using this function only. I got the same result.((
//+----------------------------------------------------------------------------+
//|  Возвращает номер бара экстремума ЗигЗага по его номеру.                   |
//|  Параметры:                                                                |
//|    sym - наименование инструмента  ("" - текущий символ)                   |
//|    tf  - таймфрейм                 ( 0 - текущий ТФ)                       |
//|    ne  - номер экстремума          ( 0 - текущий)                          |
//|    dp  - ExtDepth                                                          |
//|    dv  - ExtDeviation                                                      |
//|    bc  - ExtBackstep                                                       |
//+----------------------------------------------------------------------------+
int GetExtremumZZBar(string sym="", int tf=0, int ne=0, int dp=12, int dv=5, int bc=3) {
  if (sym=="") sym=Symbol();
  double zz;
  int    i, k=iBars(sym, tf), ke=0;
 
  for (i=1; i<k; i++) {
    zz=iCustom(sym, tf, "ZigZag", dp, dv, bc, 0, i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(i);
    }
  }
  Print("GetExtremumZZBar(): Экстремум ЗигЗага номер ",ne," не найден");
  return(0);
}
What is wrong here? Why is it screaming about errors?