What should be added for additional support of universal mathematical calculations in MQL5 and MQL5 Cloud Network? - page 6

 
Renat:

Here's the thing, Renat.

MT5 clearly understands when a stop loss is activated and when a take profit is activated. // This can be seen from order comments and is clear from the platform handling itself.

This is why we have the request (constantly). - We would like the appropriate flag to appear in OnTradeTransaction when activating an SL or TP.


But if this is impossible (even theoretically) due to lack of proper binding architecture, we'd better just say that the platform architecture does not allow us to put a flag in the order being sent to this action to confirm whether it was a SL or TP.

Although for you there is no such word as "nothing is impossible". You are metaquotes :)

 

In other words, looking at the transaction structure https://www.mql5.com/ru/docs/constants/structures/mqltradetransaction

I would add a TRADE_ACTION field

struct MqlTradeTransaction
  {
   ulong                         deal;             // Тикет сделки
   ulong                         order;            // Тикет ордера
   string                        symbol;           // Имя торгового инструмента
   ENUM_TRADE_TRANSACTION_TYPE   type;             // Тип торговой транзакции
   ENUM_TRADE_ACTION               action,            // Тип события, по какой причине выставлен ордер
   ENUM_ORDER_TYPE               order_type;       // Тип ордера
   ENUM_ORDER_STATE              order_state;      // Состояние ордера
   ENUM_DEAL_TYPE                deal_type;        // Тип сделки
   ENUM_ORDER_TYPE_TIME          type_time;        // Тип ордера по времени действия
   datetime                      time_expiration;  // Срок истечения ордера
   double                        price;            // Цена 
   double                        price_trigger;    // Цена срабатывания стоп-лимитного ордера
   double                        price_sl;         // Уровень Stop Loss
   double                        price_tp;         // Уровень Take Profit
   double                        volume;           // Объем в лотах
  };
the reasons for placing the order, respectively
SL triggered
TP triggered
Exit a position by Stop Out

and others, if there are any // though this may be all we need
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура торговой транзакции
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура торговой транзакции - Документация по MQL5
 
sergeev:

There is a point here, Renat.

MT5 clearly understands when Stop Loss is activated and when Take Profit is activated. // This can be seen in the order comments and is clear from the platform itself.

That's the thing: he doesn't understand and shouldn't understand.

Everything goes through execution queues, orders are split into simple BUY/SELL, with gateways to liquidity providers and exchanges. There is no telling how it will be executed (including partial) in reality. And if we suddenly proclaim that we guarantee stop flags, papaklass will tomorrow accuse us in righteous anger that "it didn't work for me!".

 
Renat:

That's the thing: in reality it doesn't and shouldn't.

Everything runs in queues of execution, the orders are split into simple BUY/SELL, and through the gateways to liquidity providers and exchanges.

Yes, it is splitting.

But this splitting action requires quite a specific action - to activate Stop Loss/StackProfit. And these actions are processed by MT's server , not by the client terminal.

Even if the activation of stops does not take place in MT, the result is still the creation of a real order or event for MT5.

I realise that I can't get into the bowels of the MT5 server, but you just make sure once again. Is it possible to notify about the action, on the basis of which the order is placed.

Once the server (or gateway) activates a stoploop/stackprofit/stopout, etc., the response is to place an order anyway. // Nothing happens without an order!

And here, on this order and put the appropriate flag - the reason for placing this order or event.

 
Maybe a new structure should have been introduced, specifically for TradeTransaction?
 
pronych:
Maybe a new structure should have been introduced, just for TradeTransaction?

It's not that new :) it's very complete.

There are only two fields missing

- position identifier
- reason for placing an order

 
sergeev:

Yes, it splits.

But the action for this splitting is quite specific - to activate stoploop/stackprofit. And this action is processed by MT server , not by client terminal.

The answer is simple - there is no guarantee of 100% flagging.

Because there are many sources and initiators of triggering, and it is not the only trading server.

 
Renat:

The answer is simple - there is no guarantee of 100% flagging.

For there are so many sources and triggers, and this is by no means the only trade server.

Is the activation of a stop loss really handled by several trade servers?

It seemed to me that only one trading server is sufficient for this purpose.

For the activation, an order is created and the platform is notified of its creation. // by an external gateway
then it is poured. and the trades appear.
It is understandable that the order may not be filled, and the remainder will be withdrawn.
But at the moment of this order creation we can add to the transaction a flag saying that it is a stop loss order.
The most important thing is the event itself that this is an order for a stop loss.

Or in MT there may be trades without an order if the stop loss is handled by the gateway?

But you know better, I won't argue. it's a very subtle point.
 

papaklass:

And who's doing all the talking?

Definitely you.

You're trying to troll. What's the point?

Behave yourself.

 
Renat:

We, for our part, are thinking about independent communication between agents without a terminal. For example, one of the agents can generate initial data and send it to the others by fordcast.

Without the involvement of the terminal, this is good.

Who will generate the data for this "one of the agents"? Will a script or an indicator be able to do it?

What is the communication between agents for, enlighten the unsophisticated if you can.

Already wrote a script to test the mathematical calculations capabilities, but some functions are missing)

// все данные расчетов агентов складываются в массив структур
struct MqlCloud
  {
   enum STATUS {wait,ready,error,free};
   STATUS status; // статус выполнения задачи - выполнена, выполняется, ошибка выполнения
   double input_data[]; // массив входных данных
   double out_data[];   // массив выходных данных
  };
  
long id=AccountInfoInteger(ACCOUNT_LOGIN);  

double in_data[100];
MqlCloud result[10000];
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   CloudInit(id,"myprog.ex5");  // id - это кто будет платить за Cloud, myprog.ex5 - программа которая будет выполнять расчеты
   CloudData("file.dat");       // file.dat - файл с неизменными данными для расчета
   for(uint i=0; i<10000; i++)
      {
       //
       // формируем массив входных данных для расчета
          for(int n=0; n<ArraySize(in_data); n++) in_data[n]=MathRand()/SHORT_MAX; 
       //
       CloudCalculat(i,in_data); // здесь i - номер задачи, input_data - массив переменных входных данных
      }
   // выводим максимальный результат
   double max_result=0.0; 
   for(uint i=0; i<10000; i++)
      {
       if(result[i].status!=ready)
         {
          i--;
          Sleep(1000);
          continue;
         }
       max_result=MathMax(max_result,result[i].out_data[0]);
      }
   Print("Max result = ",ArrayMaximum(result[0].out_data));
  }
  
//+------------------------------------------------------------------+
void OnCloudPass(uint num_mission)
  {
   // анализируем результат выполнения задачи по ее номеру, если нужно
   double s=result[num_mission].out_data[0];
  }
//+------------------------------------------------------------------+

void CloudInit(long ID, string programm_name) {}
void CloudData(string file_dat) {}
void CloudCalculat(uint num_mission, double & idata[]) {}