Questions from Beginners MQL5 MT5 MetaTrader 5 - page 938

 
Konstantin Nikitin:

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

Thank you. My question is much easier - I opened an order via OrderSend(request,result) and want to immediately operate with its parameters - for example, print them out. 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 ("retcode = " + retcode + "; ");        
        Print ("deal = " + deal + "; ");
        Print ("order = " + order + "; "); 
        Print ("volume = " + volume + "; ");  
        Print ("price = " + price + "; ")
Some of the parameters, such as retcode, order and volume are printed, but deal and price are not.
Especially price is of interest. All results are in MqlTradeResult. I print them all the same way but some of them are printed while others are not. The question - why certain parameters are printed while others are not?
 

How do I merge arrays?

string eData[][50][3];
string bData[][20][5];
 ArrayCopy(eData,bData,ArraySize(eData)); // error: incompatible 3 arrays ranges for ArrayCopy function (50 and 20)

I understand thatArrayCopy only copies one-dimensional arrays?

 
Vitaly Muzichenko:

How do I merge arrays?

I understand thatArrayCopy only copies one-dimensional arrays?

No, ArrayCopy copies any arrays that are allowed in mql5\4. But they should be identical to be copied. The second dimension of the first array has 50, and the second array has only 20. It is the same for the third dimension.
 
Algotrader18:
Thank you. My question is much easier - I opened an order via OrderSend(request,result) and want to immediately operate with its parameters - for example, print them out. Like this: Some of the parameters like retcode, order and volume are printed, but deal and price are not.
Especially price is of interest. All results are available in MqlTradeResult. I print them equally, but some of them are printed while others are not. The question - why certain parameters are printed while others are not?
 //============================================================
        //--- 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))
          return;
                
        Print ("retcode = " + result. retcode + "; ");        
        Print ("deal = " + result. deal + "; ");
        Print ("order = " + result. order + "; "); 
        Print ("volume = " + result. volume + "; ");  
        Print ("price = " + result. price + "; ");
 
Konstantin Nikitin:

That's how it was originally

Forum on Trading, Automated Trading Systems and Strategy Tests

Questions from beginners MQL5 MT5 MetaTrader 5

Algotrader18, 2018.10.25 07:39

Afternoon!

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.
Please, could you tell me what I am doing wrong?

Why got lost in the next code.... Question...

I think the return is unacceptable. It will be printed on the next tick.

 
Alexey Viktorov:
And I think that return is unacceptable. After all, it will be printed on the next tick.

Learning OrderSend

Returned value

If thebasic structure check (pointer check) is successful, true is returned - this does not indicate successful execution of the trade operation. To get a more detailed description of the result of the function, we should analyze the fields of the result structure .

If the basic check is passed, only then we print it. All on one tick. That's why I wrote
        if(!OrderSend(request,result))
          return;
 
Konstantin Nikitin:

Exploring OrderSend

If it passes the basic check, only then print it out. All on the same tick. That's why I wrote it.
Aha. I didn't see that one. I'm sorry...
 
Alexey Viktorov:

This was originally the case.

why was it lost in the next code... question...

But in my opinion, this one is unacceptable. It will be printed on the next tick.

I tried various variants including this one:

        ulong  deal;
        ulong  order;
        double volume;
        double price;    
          
 //============================================================
        //--- 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))

        retcode = result.retcode;
        deal = result.deal;
        order = result.order;
        volume = result.volume;
        price = result.price;
       
      
        Print ("retcode = " + retcode + "; ");        
        Print ("deal = " + deal + "; ");
        Print ("order = " + order + "; "); 
        Print ("volume = " + volume + "; ");  
        Print ("price = " + price + "; ");

I did not copy everything into the question by mistake...

 
Algotrader18:

I've tried different options, including this one:

and copied into the question by mistake...

Try to search, fxsaber once worked on this problem. I don't know what he did, I'm not interested. It's easier for me to get all these parameters in OnTradeTransaction
 
Rustam Esedulaev:
Hi all!
In mql 4 there is such a verification as IsTradeContedtBusy
Is there something similar in mql 5?
Thank you!

There is nothing similar. MT5 is multithreaded.

Reason: