Questions from Beginners MQL5 MT5 MetaTrader 5 - page 937

 

Hello!

I open a position and want to print the content of MqlTradeResult like this:


   //--- declare and initialize the trade request and result of trade request
        MqlTradeRequest request={0};
        MqlTradeResult  result={0};
        //--- parameters of request
        request.action   = TRADE_ACTION_DEAL;    // type of trade operation
        request.symbol   = Pair1;                // symbol
        request.volume   = lots;                 // volume of lot
        request.type     = oper;                 // order type
        request.price    = priceOpen;            // price for opening
        request.deviation= Slippage;             // allowed deviation from the price
        request.magic    = magic;   
 //============================================================     
        if(OrderSend(request,result))       
        Print ("result.retcode = " + result.retcode + "; ");        
        Print ("deal = " + result.deal + "; ");
        Print ("order = " + result.order + "; "); 
        Print ("volume = " + result.volume + "; ");  
        Print ("price = " + result.price + "; ");

result.retcode, order and volume are printed, but deal and price are always zeros.
Could you please tell me what I am doing wrong?

 
Algotrader18:

Hi!

I open a position and want to print the content of MqlTradeResult like this:


result.retcode, order and volume are printed, but deal and price are always zeros.
Please, what am I doing wrong?

ArticleWhere to start when creating a trading robot for the Moscow Exchange MOEX. An example of "TradeTransactionListener" listener:

Trading using robots is simple

The MQL5 language supports all the trading features of the MetaTrader 5 platform, including a large numberof trading functions for working with orders, positions and trade requests. It does not matter what market you are trading - futures, stocks, options, etc.

Using the MQL5 tools you can createa trade request and send it to the server usingOrderSend() orOrderSendAsync() functions, getthe result of its execution, view the trade history, find outthe contract specification for an instrument, processthe trade event and get a lot of other necessary information.

It is important for the developers of trading robots to understand one essential fact: every trade operation, whether it is opening a position, setting StopLoss or TakeProfit, or closing a position with a counter trade, always consists of a number of transactions performed on MetaTrader 5 server and on the Moscow Exchange. To see how this happens, you can run theTradeTransactionListener.mql5 Expert Advisor on your account which simply listens forTradeTransaction events and displays a summary of them:

//+------------------------------------------------------------------+
//|                                     TradeTransactionListener.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+


 
Has anyone encountered a problem, can't log into mt5, problem - invalid certificate?
 
Impulsive87:
Has anyone encountered a problem, can't log into mt5, problem - invalid certificate?
Is Windows real (not an emulator by any chance)? Do you connect to the broker that issued the certificate or to a regular brokerage company?
 

What are the conditions for testing to continue with the same cache in the \Tester\cache, not to create a new optimization table, but to be updated?

1 an unchanged compiled EA file ex5

2 testing conditions would not change (except balance or balance + profitability).

3 ?

 
Impulsive87:
I can't log in to mt5, problem is invalid certificate?
I ran into this problem a long time ago, check in the certificate store and in the program folder for the correct certificate
 
Vladimir Karputov:

ArticleWhere to start when creating a trading robot for the Moscow Exchange MOEX. Example of a TradeTransactionListener listener:

Thank you, but it's not exactly the same - it works with history, I need to get data from MqlTradeResult immediately after position opening. It's strange - it outputs some parameters but not others, i.e. I do something wrong. I would like to understand exactly this situation...
 
Algotrader18:

Hello!

I open a position and want to print the content of MqlTradeResult like this:


result.retcode, order and volume are printed but deal and price are always zeros.
Could you please tell me what I am doing wrong?

Try calling before printing

//+------------------------------------------------------------------+
//| Get the result structure                                         |
//+------------------------------------------------------------------+
void CTrade::Result(MqlTradeResult &result) const
  {
   result.retcode   =m_result.retcode;
   result.deal      =m_result.deal;
   result.order     =m_result.order;
   result.volume    =m_result.volume;
   result.price     =m_result.price;
   result.bid       =m_result.bid;
   result.ask       =m_result.ask;
   result.comment   =m_result.comment;
   result.request_id=m_result.request_id;
   result.retcode_external=m_result.retcode_external;
  }
from the CTrade class
 
Alexey Viktorov:

Try calling up

from the CTrade class
Thanks, would like to do it without CTrade.
 
Algotrader18:
Thanks, I'd like to do it without CTrade.

So pull the required functionality from the class and write it to yourself.

Reason: