Discussion of article "Backpropagation Neural Networks using MQL5 Matrices" - page 3

 

To work on netting accounts, it is necessary to add an explicit symbol indication to the ClosePosition function:

 bool ClosePosition()
{
    // define an empty structure
   MqlTradeRequest request = {};
   ...
   // fill in the required fields
   request.action = TRADE_ACTION_DEAL;
   request.position = PositionGetInteger(POSITION_TICKET);
   request.symbol = _Symbol;
   const ENUM_ORDER_TYPE type = (ENUM_ORDER_TYPE)(PositionGetInteger(POSITION_TYPE) ^ 1);
   request.type = type;
   request.price = SymbolInfoDouble(_Symbol, type == ORDER_TYPE_BUY ? SYMBOL_ASK : SYMBOL_BID);
   request.volume = PositionGetDouble(POSITION_VOLUME);
   ...
     
   // send the request
   ...
}
 

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Back propagation neural networks on MQL5 matrices"

Stanislav Korotky , 2024.04.16 17:34

To work on netting accounts, you need to specify symbol explicitly in the ClosePosition function:

 bool ClosePosition()
{
    // define empty struct
   MqlTradeRequest request = {};
   ...
   // fill in required fields
   request.action = TRADE_ACTION_DEAL;
   request.position = PositionGetInteger(POSITION_TICKET);
   request.symbol = _Symbol;
   const ENUM_ORDER_TYPE type = (ENUM_ORDER_TYPE)(PositionGetInteger(POSITION_TYPE) ^ 1);
   request.type = type;
   request.price = SymbolInfoDouble(_Symbol, type == ORDER_TYPE_BUY ? SYMBOL_ASK : SYMBOL_BID);
   request.volume = PositionGetDouble(POSITION_VOLUME);
   ...
     
   // send the request
   ...
}

 

An article well worth reading.

Thank you!

 

Thank you, very good article!

For some reason I had overlooked it.