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

 
Vitaly Muzichenko:

It works brilliantly!

From two positions chose the last one, namely on the 11th bar, which you can see in the screenshot:


Validation code

I decided to change the condition to enter the position, just set Limit to Low[2] worked, but when the condition as in my first call today, it does not work, so it is in the condition itself before the function is called

 
Вадим Мотеюнас:

I decided to change the condition for entering a position, just set the limit to Low[2] it worked, but when the condition as in my first call today, it does not work, so the problem is in the condition itself before the function is called

It is you who set an order and not a position entry (Buy, Sell).

Ok, so it's a good thing.

 
Vitaly Muzichenko:

It was you who set the order, not the entry into the position(Buy, Sell).

Ok, we've got it figured out - so it's good.

i meant that first there was a condition for enteringif(Open[2]>Close[2] && Open[1]>Close[1] && Close[1]<Low[2]

then I called this function to return the bar index, but now I just removed it and put Low[2] in OrderSend and it works

After all, I did not waste a day on it, it's a bit of a shift from the dead point

 
I'm over the problem, thank you all for your feedback
 
if(takelimit=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
      Print(takelimit,GetLastError());//здесь возвращает число 11, получается ошибка код 11, но не нашел расшифровку нигде?
      {if(iBarShift(Symbol(),0,OrderOpenTime())==1)
        
      deletelimit=OrderDelete(ticket);
      if(!deletelimit)
         Comment(GetLastError());
         }
 
Вадим Мотеюнас:

maybe 1 and 1 ?/i.e. true and error code 1

ERR_NO_RESULT1No error, but the result is unknown
bool takelimit;

if(takelimit=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
      Print(string(takelimit)+"   :",GetLastError());//здесь возвращает число 11, получается ошибка код 11, но не нашел расшифровку нигде?
      {if(iBarShift(Symbol(),0,OrderOpenTime())==1)
        
      deletelimit=OrderDelete(ticket);
      if(!deletelimit)
         Comment(GetLastError());
         }
 
Вадим Мотеюнас:

Your whole code is wrong.

bool takelimit;

if(takelimit?=OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
      Print(string(takelimit)+"   :",GetLastError());//здесь возвращает число 11, получается ошибка код 11, но не нашел расшифровку нигде?
      {if(iBarShift(Symbol(),0,OrderOpenTime())==1) // <<< что это, почему сравнивать с единицей? OrderOpenTime() может вернуть "1"???
        
      deletelimit=OrderDelete(ticket);
      if(!deletelimit)
         Com
 
Vitaly Muzichenko:

Your whole code is wrong.

it checks the bar number against the time there...

int ticket;

void Fn()
  {
   ResetLastError();
   if(!OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)){Print(GetLastError());}
   else
     {
      if(iBarShift(Symbol(),0,OrderOpenTime())==1 && !OrderDelete(ticket)){Comment(GetLastError());}
     }
  }
 
Nikolay Gaylis:

he checks the bar number against the time there...

Yes, didn't notice the bracket.

 
Nikolay Gaylis:

it checks the bar number by time there...

Nikolay Gaylis:

maybe 1 and 1 ?/i.e. true and error code 1

ERR_NO_RESULT1There is no error, but the result is unknown

Print(takelimit,GetLastError()) returns two values because the 1st variable is of bool type and it doesn't need GetLastError, and because it has a comma, GetLastError returns the last error in the code at the moment of calling GetLastError?

Reason: