Errors, bugs, questions - page 2380

 
bool CTrade::PositionClosePartial(const ulong ticket,const double volume,const ulong deviation,const string comment = NULL)
{
...
  m_request.comment = (comment == NULL) ? ::PositionGetString(POSITION_COMMENT) : comment;
...
 
fxsaber:

The logic that already exists is broken.

This is more interesting.

bool CTrade::PositionClosePartial(const ulong ticket,const double volume,const ulong deviation,const string comment = "")
{
...
  m_request.comment = (comment == NULL) ? ::PositionGetString(POSITION_COMMENT) : comment;
...

If we don't change calls, the comment will be overwritten as before.

If we explicitly pass NULL, we copy existing comment

 
Slava:

The logic that already exists is being violated.

Nobody uses that logic. All the more reason to use it.

 
Slava:

The logic that already exists is broken.

This is more interesting.

If you don't change the challenges, the comment will be overwritten as before.

If explicitly pass NULL, then copy existing comment

Please have a look and

bool CTrade::PositionClose(const string symbol,const ulong deviation)

it makes 10 (!!!) attempts to close a position:( I had such situations when debugging (Netting, Real, Opening):

2019.01.28 16:58:11.764 57384742        Si-3.19 buy     in      1.00    66492   98591318        -1.03   0.00    0.00            Price=66493
2019.01.28 17:01:14.586 57384818        Si-3.19 sell    out     1.00    66503   98591566        0.00    0.00    11.00           
2019.01.28 17:01:14.598 57384819        Si-3.19 sell    in      1.00    66502   98591567        -1.03   0.00    0.00            
2019.01.28 17:04:16.067 57385000        Si-3.19 buy     out     1.00    66514   98591891        0.00    0.00    -12.00          

the highlighted line is the 2nd attempt to close a position :) As you can see from the logs it was not entirely successful

At the moment I am using it:

bool CTrade::PositionClose(const ulong ticket,const ulong deviation)

There is already one attempt to close position by code. It seems correct to let the user control the fact of position closing. 10 attempts is not a panacea

 
Slava:

The logic that already exists is broken.

This is more interesting.

If we don't change calls, the comment will be overwritten as before.

If we explicitly pass NULL, we copy existing comment

Or maybe it will be more convenient.

bool CTrade::PositionClosePartial(const ulong ticket,const double volume,const ulong deviation,const string comment = NULL)
{
...
  m_request.comment = (comment == NULL) ? ::PositionGetString(POSITION_COMMENT) : comment;
...

Then whoever needs it will overwrite it with an empty value. The default value will be copied.

 

Dear developers!

The terminal was updated to 1983. There are some strange errors in the tester when creating graphical objects (I am creating vertical lines and trend lines). In 1981 everything was normal.

Now I get errors 4001.

Creation code:

//+------------------------------------------------------------------+
//| Создаем трендовую линию на чарте                                                                                    |
//+------------------------------------------------------------------+
void DrawTrendLine(const string id,// Строковый идентификатор
                   const datetime t1,         // Время первой точки линии
                   const datetime t2,         // Время второй точки линии
                   const double price,// Цена обеих точек линии
                   const color clr            // Цвет линии
                   )
  {
//--- Формируем имя линии
   const string name=_prefix+id+TimeToString(t1)+"_"+TimeToString(t2);
//--- Сбрасываем код последней ошибки
   ResetLastError();
//---
//Print( __FUNCTION__,": Создаем тренд-линию "+name+": t1 = "+TimeToString( t1 )+", t2 = "+TimeToString( t2 )+", price = "+DoubleToString( price ) );
//--- Создаем объект, проверяем создание
   if(ObjectCreate(0,name,OBJ_TREND,0,t1,price,t2,price))   // Если объект создан
     {
      //--- Меняем свойства линий
      ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
      ObjectSetInteger(0,name,OBJPROP_BACK,true);
      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
      ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_DOT);
      ObjectSetInteger(0,name,OBJPROP_RAY_LEFT,false);
      ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,false);
     }
   else                                                 // Если объект не создан
   Print(__FUNCTION__,": ОШИБКА #",GetLastError(),": Объект '"+name+"' не построен! t1 = "+TimeToString(t1)+", t2 = "+TimeToString(t2)+", price = "+DoubleToString(price));
  }
//+------------------------------------------------------------------+
//| Создаем вертикальную линию на чарте                              |
//+------------------------------------------------------------------+
void DrawVLine( const string id,         // Строковый идентификатор
               const datetime time      // Время
               )
  {
//--- Формируем имя линии
   const string name=_prefix+id+TimeToString(time);
//--- Сбрасываем код последней ошибки
   ResetLastError();
//--- Создаем объект, проверяем создание
   if(ObjectCreate(0,name,OBJ_VLINE,0,time,0))   // Если объект создан
     {
      //--- Меняем свойства линий
      ObjectSetInteger(0,name,OBJPROP_COLOR,_vLineClr);
      ObjectSetInteger(0,name,OBJPROP_BACK,true);
      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
      ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_DOT);
     }
   else                                                 // Если объект не создан
   Print(__FUNCTION__,": ОШИБКА #",GetLastError(),": Объект '"+name+"' не построен! t1 = "+TimeToString(time));
  }
 
Also, the comments in the tester are no longer displayed.
 

Question for developers.

Themytrade.PositionClose(conststring symbol,ulong deviation=ULONG_MAX) function of the standard library is missing a comment parameter:conststring comment="".

Is it an oversight ?

 

It seems more appropriate to write here:

https://www.mql5.com/ru/forum/302709#comment_10570043

Вопросы по проектам / папки Projects и Shared Projects
Вопросы по проектам / папки Projects и Shared Projects
  • 2019.02.08
  • www.mql5.com
Попытался начать работать с проектами, но что-то не ладится. Допустим, уже есть исходный файл с инклудами...
 
Remove STATUS_TERMINAL_PATH from the Documentation.
Reason: