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

 

Good afternoon, Mr. Professionals! I solve all the MQL5 programming basics by solving programming tasks from the book "Programming Tasks" by S.A. Abramov (Programmer's Library) - 1988. I've done another one and am trying to solve it. Made a flowchart. Help a beginner. Can you tell me how to organize transitions? Or give me a link where I can read about transitions. Thank you very much.

Files:
9tb21j_36.png  10 kb
 
vladeimirami #:

Good afternoon, Mr. Professionals! I solve all the MQL5 programming basics by solving programming tasks from the book "Programming Tasks" by S.A. Abramov (Programmer's Library) - 1988. I've done another one and am trying to solve it. Made a flowchart. Help a beginner. Can you tell me how to organize transitions? Or give me a link where I can read about transitions. Thank you very much.

The if-else operator

Документация по MQL5: Основы языка / Операторы / Условный оператор if-else
Документация по MQL5: Основы языка / Операторы / Условный оператор if-else
  • www.mql5.com
Условный оператор if-else - Операторы - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin #:

If-else statement

Thank you for your feedback. I'm having a hard time with this subject, though. But persistence never fails me. Could you give me a very small example. I apologize for my technical language in programming.
 
vladeimirami #:
How do I go from a lower point in the programme to an earlier point in the programme.

The question is somewhat abstract.

Read about operators

Документация по MQL5: Основы языка / Операторы
Документация по MQL5: Основы языка / Операторы
  • www.mql5.com
Операторы - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Tretyakov Rostyslav #:

The question is somewhat abstract.

Read about operators

How do I get from point B to point A? Roughly speaking, I need some kind of prototype go-to operator
Files:
6l69ux_36.1.png  10 kb
 
vladeimirami #:
How do I get from point B to point A? Roughly speaking, you need some kind of prototype go-to operator
There is no such thing. This is not a procedural language. The program here is strictly top-down. And function calls solve everything there are loops, if that. AND OOP)
 
Valeriy Yastremskiy #:
There is no such thing. This is not a procedural language. Here the program is strictly top-down. And function calls solve everything there are loops, if that. AND OOP)
Got it. Got it. Thanks for the clarification.
 
Tretyakov Rostyslav #:

Thank you!

 
Tretyakov Rostyslav #:

Hi

    if(OrderSelect(FindTicketOrder(), SELECT_BY_TICKET,MODE_TRADES)) 
    { 
      if(OrderProfit()<=-x);
        {
         OrderClose(FindTicketOrder(),OrderLots(),OrderClosePrice(),iSlippage,clrPink);
        }
    } 
  else 
    Print("OrderSelect() вернул ошибку - ",GetLastError());

Got a profit order on a ticket, I want to close when it reaches -x.

But I get all orders closed in a row.

Can you tell me how to do this correctly?

 
Alexander Avksentyev #:

Hi

Got a profit order on a ticket, I want to close when it reaches -x.

But I get all orders closed in a row.

Can you tell me how to do it correctly?

Try to do it in this way

 int min_ticket=FindTicketOrder();
    if(OrderSelect(min_ticket, SELECT_BY_TICKET,MODE_TRADES)) 
    { 
      if(OrderProfit()<=-x);
        {
         OrderClose(min_ticket,OrderLots(),OrderClosePrice(),iSlippage,clrPink);
        }
    } 
  else 
    Print("OrderSelect() вернул ошибку - ",GetLastError());

In general, you should develop the whole function to understand what you are doing

//+------------------------------------------------------------------+
void Функция()
  {
   ...твой код, возможные ошибки;
  }
//+------------------------------------------------------------------+
Reason: