Errors, bugs, questions - page 73

 
Swan:

or no override is needed, or ask,bid by position symbol to request

The PositionGetSymbol function automatically selects a position for further work.

In fact, PositionGetSymbol provides sequential selection and PositionSelect provides direct selection

Документация по MQL5: Торговые функции / PositionGetSymbol
Документация по MQL5: Торговые функции / PositionGetSymbol
  • www.mql5.com
Торговые функции / PositionGetSymbol - Документация по MQL5
 
Swan:

or you don't need to search for a position, or ask, bid by a position symbol

As it turned out, PositionGetInteger(POSITION_TYPE) is used without selection by PositionSelect. Which, in fact, is not good (as Slava reminded me)... :)

stringo:

The PositionGetSymbol function automatically selects a position for further work.

In fact, PositionGetSymbol provides sequential selection and PositionSelect provides direct selection

Based on this it was necessary to apply exactly PositionGetSymbol in the loop, and then to be interested in everything else...
 

Well, if using telepathy, then if(PositionSelect(Symbol())) you must put it instead of loop :)

It's better to check if LevelProfit-LevelWLoss is not less than SymbolInfoInteger(Symbol,SYMBOL_TRADE_STOPS_LEVEL).

And those doubles are compared incorrectly...

Otherwise should work)


ps: not sure, but for sl/tp modification, deviation>0 will not add anything good.

 

ObjectGetInteger() with identifier OBJPROP_TIME does not work correctly

To reproduce the error, create a "Rectangle" object named "1"

Run the script below to show the four anchor coordinates of our freshly created rectangle named "1"

void OnStart()
{ 
  Comment(ObjectGetDouble(0,"1",OBJPROP_PRICE,0),"   ",
          StringToTime   (IntegerToString(ObjectGetInteger(0,"1",OBJPROP_TIME, 0))),"\n",
          
          ObjectGetDouble(0,"1",OBJPROP_PRICE,1),"   ",
          StringToTime   (IntegerToString(ObjectGetInteger(0,"1",OBJPROP_TIME, 1))));

}

We see that the price coordinates are defined correctly, but the time coordinates are not:


Документация по MQL5: Графические объекты / ObjectGetInteger
Документация по MQL5: Графические объекты / ObjectGetInteger
  • www.mql5.com
Графические объекты / ObjectGetInteger - Документация по MQL5
 
joo:

ObjectGetInteger() with identifier OBJPROP_TIME does not work correctly

To reproduce the error, create a "Rectangle" object named "1"

Run the script below to show the four anchor coordinates of our freshly created rectangle named "1"

We see that the price coordinates are defined correctly, but the time coordinates are not:



Feel the difference

  Comment(ObjectGetDouble(0,"1",OBJPROP_PRICE,0),"   ",
          datetime(ObjectGetInteger(0,"1",OBJPROP_TIME, 0)),"\n",
          
          ObjectGetDouble(0,"1",OBJPROP_PRICE,1),"   ",
          datetime(ObjectGetInteger(0,"1",OBJPROP_TIME, 1)));
 
joo:

ObjectGetInteger() with identifier OBJPROP_TIME does not work correctly

To reproduce the error, create a "Rectangle" object named "1"

Run the script below to show the four anchor coordinates of our freshly created rectangle named "1"

We see that the price coordinates are defined correctly, but the time coordinates are not:



Here's the script.

//+------------------------------------------------------------------+
//|                                                       123123.mq5 |
//|                                  2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   string msg="";
//---
   msg+=DoubleToString(ObjectGetDouble(ChartID(),"123456",OBJPROP_PRICE,0),_Digits)+" "+
        TimeToString(ObjectGetInteger(ChartID(),"123456",OBJPROP_TIME,0),TIME_DATE|TIME_MINUTES)+"\n";
   msg+=DoubleToString(ObjectGetDouble(ChartID(),"123456",OBJPROP_PRICE,1),_Digits)+" "+
        TimeToString(ObjectGetInteger(ChartID(),"123456",OBJPROP_TIME,1),TIME_DATE|TIME_MINUTES)+"\n";
   Comment(msg);
  }
//+------------------------------------------------------------------+

And here is the result.

 
stringo:

Feel the difference

Thank you, I feel the difference.

You explicitly set the value type to datetime

and I used data conversion.

But doesn't that mean that the construct

StringToTime   (IntegerToString(

doesn't work correctly?

 
joo:

Thank you, I feel the difference.

You explicitly set the value type to datetime

and I used data conversion.

But doesn't that mean that the construct

Isn't it working correctly?

Not that it's wrong. These actions are just unnecessary.

Look through the help for the StringToTime() function and you will understand why the result is incorrect.

Документация по MQL5: Преобразование данных / StringToTime
Документация по MQL5: Преобразование данных / StringToTime
  • www.mql5.com
Преобразование данных / StringToTime - Документация по MQL5
 
joo:

Thank you, I feel the difference.

You explicitly set the value type to datetime

and I used data conversion.

But doesn't that mean that the construct

doesn't work correctly?

Not exactly. By converting IntegerToString you received a string of the "12345612345" type, while StringToTime should input a string formatted as "2010.07.29 08:10".

However, you have shown us our mistake. In your case, we should have returned the date 1970.01.01 00:00 and set last_error

 
stringo:

Not exactly. By converting IntegerToString you received a string of the type "12345612345", while StringToTime should receive a string formatted as "2010.07.29 08:10".

However, you have shown us our mistake. In your case, we should have returned the date 1970.01.01 00:00 and set last_error

So, my message is not in vain, as I already thought?
Reason: