Errors, bugs, questions - page 668

 

If you focus on the colours in the Price tumblr, there seems to be confusion.

//---

The Buy button is blue. Therefore, the prices at which you can place a bid should also be blue. Now it's the other way round and you have to work hard to get used to it and it's unlikely to work. It's a psychological nuance. )))

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Виды заявок в стакане цен
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Виды заявок в стакане цен
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Виды заявок в стакане цен - Документация по MQL5
 

Based on the information relating to the Price Stack in the Help, the layout for the test would look something like this:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   MarketBookAdd(_Symbol);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   MarketBookRelease(_Symbol);
  }
//+------------------------------------------------------------------+
//| OnBook Event                                                     |
//+------------------------------------------------------------------+
MqlBookInfo priceArray[];
//---
void OnBookEvent(const string &symbol_name)
  {
   bool getBook=MarketBookGet(_Symbol,priceArray);
//---
   if(!getBook)
     {
      Print("Не удалось получить содержимое стакана по символу ",Symbol());
     }
  }
//+------------------------------------------------------------------+
//| OnChart event handler                                            |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   double price_buy=0.0,price_sell=0.0;
//---
   TRADE_EXEMODE=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_EXEMODE); // Узнаем тип исполнения
//---
   if(TRADE_EXEMODE==SYMBOL_TRADE_EXECUTION_MARKET ||
            TRADE_EXEMODE==SYMBOL_TRADE_EXECUTION_EXCHANGE)
     {
      mytrade.SetTypeFilling(ORDER_FILLING_IOC);
      //---
      if(TRADE_EXEMODE==SYMBOL_TRADE_EXECUTION_EXCHANGE)
        {
         int size=ArraySize(priceArray);
         //---
         for(int i=size-1; i>=0; i--)
           {
            if(priceArray[i].type==1)
              {
               price_buy=priceArray[i].price; // Получим ближайшую цену для BUY
               price_sell=priceArray[i+1].price; // Получим ближайшую цену для SELL

               //---
               break;
              }
           }
        }
      else
        {
         price_buy=mylast_tick.ask;
         price_sell=mylast_tick.bid;
        }
     }
//---
   //... Далее следуют функции для совершения торговых операций
  }

//---

However, when making a trade, the Expert Advisor log displays a message, from which it can be seen that although there was a price in the query, it was the closest one in the Depth of Market:

price_request=mytrade.RequestPrice();

the result is no price (0.000):

price_result=mytrade.ResultPrice();

and the trade function returns false:

//---

In the log we can see that there was an attempt to open a position at zero price:

but the position was nevertheless opened at the current price.

//---

If this information is not enough to determine which side is at fault, I will write to Service Desk.

 

Can you tell me how to remove a pending order?

trReq.order=order_ticket;

trReq.type=TRADE_ACTION_REMOVE;

OrderSend(trReq,trRez);

My compiler gives me: TRADE_ACTION_REMOVE can't convert enum

and 2 times about the same error.

tried the same way with zeroing before:

trReq.symbol =Symbol(); //NULL

trReq.magic =MAGIC; //0

trReq.volume =0.0;

trReq.type =0;

trReq.price =0.0;

trReq.sl =0.0;

trReq.tp =0.0;

trReq.type_time =0;

trReq.expiration=0;

does not work. build 597.

Give me a complete example please. Thank you in advance.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций - Документация по MQL5
 
stroka:
...

Give a complete example please. Thank you in advance.

There is a complete example in the standard library. Function OrderDelete(). It has documentation. You can also take there functions for all trading operations.

//+------------------------------------------------------------------+
//| Delete specified pending order.                                  |
//| INPUT:  ticket - ticket of order for delete.                     |
//| OUTPUT: true-if successful, false otherwise.                     |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CTrade::OrderDelete(ulong ticket)
  {
//--- variables
   string action,result;
//--- check stopped
   if(IsStopped(__FUNCTION__)) return(false);
//--- clean
   ClearStructures();
//--- setting request
   m_request.action    =TRADE_ACTION_REMOVE;
   m_request.order     =ticket;
//--- order check
   if(!OrderCheck(m_request,m_check_result))
     {
      //--- copy return code
      m_result.retcode=m_check_result.retcode;
      if(m_log_level>LOG_LEVEL_NO)
         printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
      return(false);
     }
//--- order send
   if(!OrderSend(m_request,m_result))
     {
      if(m_log_level>LOG_LEVEL_NO)
         printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
      return(false);
     }
   if(m_log_level>LOG_LEVEL_ERRORS)
      printf(__FUNCTION__+": %s [%s]",FormatRequest(action,m_request),FormatRequestResult(result,m_request,m_result));
//--- ok
   return(true);
  }
 
The terminal does not log in to the mql5 community. I enter the login and password in the terminal settings, press ok and nothing happens. When I enter the settings again, the login is saved, but the password is blank. I can't download anything from the market. I can enter the forum without any problems.
 
Dima_S:

What is the purpose of truncating a string when you set it as an external parameter?

input string - max 105 characters can be specified, if more than that, it gets clipped on the right.

build 597

buid 607 - same problem.
 

please tell me why the following code does not find the corresponding window (I checked, the window with this class exists)

#import "user32.dll"
   int FindWindowA(string &lpClassName, string &lpWindowName);
#import

string FormClass="TMyMainForm";
string FormName="";
int hnd = FindWindowA(FormClass,FormName);
if (hnd==0) printf("not found");
else printf("found");
 

It looks like there is some kind of error in

//+------------------------------------------------------------------+
//| Open position.                                                   |
//| INPUT:  symbol     -symbol for trade,                            |
//|         order_type -direct for open,                             |
//|         volume     -volume of position,                          |
//|         price      -price for open,                              |
//|         stop       -price of stop loss,                          |
//|         take       -price of take profit,                        |
//|         comment    -comment of position.                         |
//| OUTPUT: true-if successful, false otherwise.                     |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
bool CTrade::PositionOpen(const string symbol,ENUM_ORDER_TYPE order_type,double volume,
                          double price,double sl,double tp,const string comment)

With return code 10008 (order placed), this method returns false.

The order is finally executed.

Because of this, more than the required number of orders were opened on the demo account.

RQ      0       Trades  14:00:18        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
IO      0       Trades  14:00:18        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
MH      0       Trades  14:00:18        '3119321' : exchange buy 0.10 USDCHF at 0.00000
MQ      0       Trades  14:00:18        '3119321' : deal #2888080 buy 0.10 USDCHF at 0.91144 done (based on order #4880065)
NL      0       Trades  14:00:18        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
MK      0       Trades  14:00:18        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
IS      0       Trades  14:00:18        '3119321' : exchange buy 0.10 USDCHF at 0.00000
MN      0       Trades  14:00:19        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
NE      0       Trades  14:00:19        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
JQ      0       Trades  14:00:19        '3119321' : exchange buy 0.10 USDCHF at 0.00000
PJ      0       Trades  14:00:19        '3119321' : deal #2888081 buy 0.10 USDCHF at 0.91144 done (based on order #4880066)
KG      0       Trades  14:00:20        '3119321' : deal #2888082 buy 0.10 USDCHF at 0.91145 done (based on order #4880067)
KF      0       Trades  14:00:20        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
LM      0       Trades  14:00:20        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
HJ      0       Trades  14:00:20        '3119321' : exchange buy 0.10 USDCHF at 0.00000
DR      0       Trades  14:00:20        '3119321' : deal #2888083 buy 0.10 USDCHF at 0.91146 done (based on order #4880068)
HR      0       Trades  14:00:21        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
OJ      0       Trades  14:00:21        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
CE      0       Trades  14:00:21        '3119321' : exchange buy 0.10 USDCHF at 0.00000
MN      0       Trades  14:00:21        '3119321' : deal #2888084 buy 0.10 USDCHF at 0.91146 done (based on order #4880069)
DI      0       Trades  14:00:21        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
CF      0       Trades  14:00:21        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
OP      0       Trades  14:00:21        '3119321' : exchange buy 0.10 USDCHF at 0.00000
GI      0       Trades  14:00:22        '3119321' : deal #2888085 buy 0.10 USDCHF at 0.91146 done (based on order #4880070)
QD      0       Trades  14:00:22        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
JS      0       Trades  14:00:22        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
NK      0       Trades  14:00:22        '3119321' : exchange buy 0.10 USDCHF at 0.00000
MD      0       Trades  14:00:22        '3119321' : deal #2888086 buy 0.10 USDCHF at 0.91146 done (based on order #4880071)
NS      0       Trades  14:00:23        '3119321' : accepted exchange buy 0.10 USDCHF at 0.00000
MH      0       Trades  14:00:23        '3119321' : exchange buy 0.10 USDCHF at 0.00000 placed for execution
IG      0       Trades  14:00:23        '3119321' : exchange buy 0.10 USDCHF at 0.00000
....

And the Expert Advisor log

(EURUSD,H1)     14:00:18        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:18        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:19        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:20        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:21        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:21        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:22        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:23        CTrade::PositionOpen:  [placed]
(EURUSD,H1)     14:00:23        CTrade::PositionOpen:  [placed]
....

Please, tell me, when might there be a situation where a market order was placed on the server but wasn't executed (even partially)?
Документация по MQL5: Торговые функции / OrdersTotal
Документация по MQL5: Торговые функции / OrdersTotal
  • www.mql5.com
Торговые функции / OrdersTotal - Документация по MQL5
 
olyakish:

There seems to be an error in

With return code 10008 (order placed), this method returns false.

The order does end up being executed.

Because of this, more than the required number of orders were opened on the demo account.

And the expert log

Tell me when there may be a situation when a market order is placed on the server but is not executed (even partially)?

The same problem is described at the very beginning of the page. It is described here: https://www.mql5.com/ru/forum/1111/page679#comment_164002. No reply has been given yet.

//---

Where do you have your demo account open?

 
tol64:

The same problem is described at the very beginning of the page. Here it is: https://www.mql5.com/ru/forum/1111/page679#comment_164002. No answer has been given yet.

//---

Where do you have your demo account open?

1. Late to see this thread.

2. At A*****i.

And I posted this in humour on forum 4, but I think it should be here too :

I am parsing Expert Advisor's flights (MT5) and found this in the logs

.....(EURUSD,H1)        16:43:16        CTrade::PositionClose:  [not enough money]
... Where ... in the DC ???