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

 
Valeriy Yastremskiy:

I don't understand, how can I track the moment a position is closed, other than by querying the state of the position on every tick? Of course, not all positions are queried, but there is still a query on every tick.

Study the documentation carefully.

Документация по MQL5: Обработка событий / OnTradeTransaction
Документация по MQL5: Обработка событий / OnTradeTransaction
  • www.mql5.com
При обрабокте транзакций типа TRADE_TRANSACTION_REQUEST для получения дополнительной информации необходимо анализировать второй и третий параметры функции OnTradeTransaction() – Отправка торгового запроса на покупку приводит к цепи торговых транзакций, которые совершаются на торговом счете: 1) запрос  принимается на обработку, 2) далее для...
 
Yevhenii Levchenko:
It is not checked on every tick. If there is a signal, it starts checking and opens a deal. That's all :)

In mql4, for lack of a cook *** the janitor. The question was about mql5

 
Alexey Viktorov:

Study the documentation carefully.

Thank you. If we replace the order with an order, it is easier to understand. I haven't seen that the order-order execution is a deal. In general, it is difficult to write and implement.)))
But yes. There is noOnTradeTransaction() in mt4.
 
Valeriy Yastremskiy:
Thank you. If the order is replaced by an order it is easier to understand. I didn't see that the execution of an order-order is a deal. All in all, it's complicatedly written and implemented.))
As it is, yes. There is noOnTradeTransaction() in mt4.

You'd better try to accept the terminology you have and not substitute your own. You will get used to it in time, and you will understand it depending on the language you are using. On the contrary, in MT4, a market order is better to be called a position. That's the way many people understand it.

 
Alexey Viktorov:

You'd better try to accept the terminology as it is, rather than substituting your own. Over time you will get used to it and you will understand it depending on which language you are talking about. Even vice versa, in MT4 a market order is better referred to as a position. That's the way many people understand it.

Mystery understandings))) take profit and stop loss are orders. Orders would be clearer. The confusion comes from mt4 where an order is an order, a trade and a position. That's why I say order in mt5 and mean orders)
 

how to initialise such a structure?

struct Data
  {
   double            open[];
   double            high[];
   double            low[];
   double            close[];
  };

   Data rates[5]= {0.0,0.0,0.0,0.0}; //ошибка
 
Fast235:

how to initialise such a structure?

4 to 5. I don't know the syntax. It seems like it should be in a 2-dimensional array by logic.
 
Fast235:

how to initialize such a structure?

no way ( only each field of the structure one by one )

you need to set the size of the arrays, you could write a constructor for that, but there will be a problem - the syntax won't allow you to create an array of structures with a constructor

solution - use a class instead of the structure and use pointers, you can initialize the arrays sizes in the class constructor, and the data can be copied into them


Valeriy Yastremskiy:
4 to 5. I don't know the syntax. It should be in the 2-dimensional array by logic.
struct S
  {
   int a;
   double b;
  };

//+------------------------------------------------------------------+
void OnStart()
{
   S s[2] = {{1, 1.1},{9, 9.9}};
   ArrayPrint(s);
}
//+------------------------------------------------------------------+

2020.09.23 08:27:09.554 tst (EURUSD,H1) [a] [b]

2020.09.23 08:27:09.554 tst (EURUSD,H1) [0] 1 1.10000

2020.09.23 08:27:09.554 tst (EURUSD,H1) [1] 9 9.90000

 
Fast235:

how to initialise such a structure?

   Data rates[5]= {0.0,0.0,0.0,0.0}; //ошибка

Initialise and nullify are different concepts. If zeroing, judging from your attempts, is like this

  ZeroMemory(rates);
 
Igor Makanu:

no way ( only each field of the structure one by one )

you need to set the size of arrays, you can write a constructor for this, but there will be a problem - the syntax will not allow to create an array of structures with the constructor

solution - use class instead of structure and use pointers, then you can in the class constructor initialize the arrays sizes, and the data can be copied into them


2020.09.23 08:27:09.554 tst (EURUSD,H1) [a] [b]

2020.09.23 08:27:09.554 tst (EURUSD,H1) [0] 1 1.10000

2020.09.23 08:27:09.554 tst (EURUSD,H1) [1] 9 9.90000

Thanks. Parentheses)))) not array syntax)