Questions from Beginners MQL5 MT5 MetaTrader 5 - page 804

 
fxsaber:

Print the result of OrderCheck and its full structure. Do the same with OrderSend.

Set up demo accounts on ten different trading servers. And try your code there. Most often some particular feature of the trading server is not taken into account, which is reproduced when checking in the Market.

And don't forget to output LastError. All this together will allow you to figure out the causes of the error very quickly.


Thanks, I'll give it a try!
 
Andrii Djola:

Help me to understand the situation, I have an EA in the Strategy Tester, everything goes without errors and problems on a demo account, also no problems, but when I load the EA in the Market, the Autotester writes:

The problem has been studied far and wide. Read the article carefully, it's called something like "what tests the EA should pass ...".

It's all described there.

 

I am asking for help in solving this problem. When opening an order in the market with a volume greater than 1 on Moex, a strange phenomenon occurs: the order is traded on the market and the information about the trading comes partially, due to which OnTrade() is called earlier - how do I check if I want to wait until all information about the traded order arrives?

 
Vladimir Karputov:
Question about OnTradeTransaction function, example how to catch the closing of a position.



Thanks, turns out I was doing it right and the print is wrong. Monday is wiser than Friday, or something like that)

How do I get the price of the nearest ORDER_TYPE_BUY_LIMIT from all the set ones, to ORDER_PRICE_CURRENT?


 
lil_lil:

Thanks, turns out I was doing it right and the print is wrong. Monday is wiser than Friday, or something like that)

How do I know the price of the nearest ORDER_TYPE_BUY_LIMIT out of all the set ones, to ORDER_PRICE_CURRENT?



Bypass the entire list of pending orders, select pending orders by current symbol, by magik (optional), select pending orders of the required type only:

ORDER_TYPE_BUY_LIMIT

ORDER_TYPE_SELL_LIMIT

//+------------------------------------------------------------------+
//|                                             Find the nearest.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
//---
#include <Trade\OrderInfo.mqh>
COrderInfo     m_order;                      // pending orders object
#property script_show_inputs
//--- input parameters
input ENUM_ORDER_TYPE   order_type=ORDER_TYPE_BUY_LIMIT;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   ulong order_ticket=ULONG_MAX;
   double order_distance=DBL_MAX;

   for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
      if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties
         if(m_order.Symbol()==Symbol()/* && m_order.Magic()==m_magic*/)
            if(m_order.OrderType()==order_type)
              {
               double distance=MathAbs(m_order.PriceCurrent()-m_order.PriceOpen());
               if(distance<order_distance)
                 {
                  order_distance=distance;
                  order_ticket=m_order.Ticket();
                 }
              }
   if(order_ticket!=ULONG_MAX && order_distance!=DBL_MAX)
      Comment("Order ",EnumToString(order_type),
              ", ticket ",IntegerToString(order_ticket),
              ", distance ",DoubleToString(order_distance,Digits()));
  }
//+------------------------------------------------------------------+
Files:
 
Vladimir Karputov:

Bypass the entire list of pending orders, select pending orders by current symbol, by magik (optional), select pending orders of the required type only:


Thanks, ran to the locksmith, clicked the ad ).

 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 

I can't solve a simple problem.

In the EA, when getting the indicator handle...

int OnInit()
  {
//--- Получить хэндл индикатора Envelopes_upper для отрисовки верхней линии
   EnvHandle_upper=iEnvelopes(NULL,0,Period_upper,0,MODE_SMA,PRICE_MEDIAN,Deviation_upper);

....terminal draws both lines, but I only need the top line.

How to disable drawing of this line? I.e. change its colour to CLR_NONE, or line style to DRAW_DONE?

 
Can you tell me how to subscribe to the signal from your phone? There is no "subscribe" button on the website, I've looked through it all... And in mt5 there is nothing at all about the signals (
 
VSPro:
Please advise how I can subscribe to the signal from my phone? My device has no "subscribe" button on my website... I tried to open it all. In MT5 there is nothing at all about the signals (

You can't. You have to subscribe from a Windows desktop computer, and MetaTrader 5 must be installed on this computer.