Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 374

 
 while (Count < FindPeak)
   {
// - 2 - ======================== Поиск одного экстремума ЗЗ ============================ 
    double ZZCur = 0;
    while(ZZCur == 0 && i < Bars)
      {
       if(iCustom(Symbol(), 0, "FastZZ", Depth, 0, i)!=0.0) ZZCur =iCustom(Symbol(), 0, "FastZZ", Depth, 0, i);
       else  if(iCustom(Symbol(), 0, "FastZZ", Depth, 1, i)!=0.0) ZZCur =iCustom(Symbol(), 0, "FastZZ", Depth, 1, i);
       i++;
      }
// - 2 - ============================ Окончание блока ===================================

// - 3 - ======================== Анализ найденного экстремума ========================== 
    if (ZZCur == 0)
      return(False);           // Если ни один из экстремумов не определен, то это ошибка
 
Novaja:

Here is another variant similar to yours ... The title of the for loop says i++, so I removed the braces at the bottom. I removed curly braces because there is only one operator in the loop (if else)

 while (Count < FindPeak)
 {
    double ZZCur;
    for(i=0,ZZCur=0; ZZCur==0 && i<Bars; i++)
       if      (iCustom(NULL, 0, "FastZZ", Depth, 0, i)!=0.0) ZZCur =iCustom(Symbol(), 0, "FastZZ", Depth, 0, i);
       else  if(iCustom(NULL, 0, "FastZZ", Depth, 1, i)!=0.0) ZZCur =iCustom(Symbol(), 0, "FastZZ", Depth, 1, i);

    if (ZZCur == 0) return(False);   // Если ни один из экстремумов не определен, то это ошибка
.......
}
 
STARIJ:

Here is another variant similar to yours ... The header of the for loop says i++ so I removed them at the bottom. Removed curly braces because there is only one operator in the loop (if else)


Thanks so much for the alternative, all in the piggy bank, need to get experience. So I had it right too, just owls don't want to open trades, I'll keep looking.

 

Hello! There is an array of order open prices. Knowing the index of this order, how do I determine its type?

if(index_elementa_masiva=OP_BUY)???
 
vikzip:

Hello! There is an array of order open prices. Knowing the index of this order, how can we determine its type?

For this kind of task, it is not very desirable to have an array of opening prices, as there could hypothetically be more than one order with the same opening price.

But in general, we should take the known open price, loop through all orders and select those whose open price is equal to the one in the array with the known index.

Then, if there is more than one such order, we have to compare them by other criteria, for example by time, in order to understand that this is the order you need.

And if there is only one order, then it is the right one - without further selection by other criteria.

 
Artyom Trishkin:

It is not desirable to have an array of open prices for this task, as there could hypothetically be more than one order with the same open price.

But in general, we should take the known open price, loop through all orders and select those whose open price is equal to the one in the array by the index you know.

Then, if there is more than one order, we should compare them by other criteria, for example, by time, to understand that this is the right order.

And if there is only one, then it is the right one - without further selection by other criteria.


Thank you!

 
Can you tell me how to write a condition that says: if the order types are the same?
 bool TYP_A=OrderType;
 bool TYP_B=OrderType;
 if (TYP_A=TYP_B)????
double PriceBlizkoA;                          // Цена выбранного ордера
         bool TYP_A; 
   for(int i=1; i<=OrdersTotal(); i++)          // Цикл перебора ордер
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:  
        if (OrderOpenPrice=PriceBlizkoA);                                     //если цена ордера равна цене заданого   и вот здесь ошибка. Догадываюсь неверно записано условие. Подскажите, что исправить?
         TYP_A=OrderType;   
 
vikzip:
Can you please tell me how to write a condition that sounds like this: if order types are the same?
Read what a comparison operator is and what an assignment operator is and how they are written.
 
vikzip:
Could you please tell me how to write the condition which sounds like this: if order types are the same?

This amounts to the same thing:

bool TYP_A=OrderType;
bool TYP_B=OrderType;

bool TYP_A=0; // Buy
bool TYP_B=1; // Sell

As a result, we get

if(TYP_A) // false
if(TYP_B) // true
Read what Artiom advised.
 

Good day all!

Please give me a command for the robot not to open more than 1 order per 1 candle.

Even if he took his take on this candle - not to open the next order on the same candle.

Now it comes out that if the conditions of the indicators are fulfilled - open a trade.

When a deal on the take is closed, it immediately opens a new deal on the same candlestick, and here it is no longer needed and creates problems for me.

I feel it is important to give some feedback.

It needs a strictly so 1 candle - 1 deal.

Many thanks in advance!