Errors, bugs, questions - page 2101

 
damirqa:

Hello, I have started studying MQL5 sincehttps://www.mql5.com/ru/articles/100. I have launched the code and got error 4756. I have looked through the documentation and it was no better. I thought I would start with something simple (Alert/Print...). One of the most important functions is OrderSend. I started searching through the forum/documentation on how to use OrderSend. I found this articlehttps://www.mql5.com/ru/docs/constants/tradingconstants/enum_trade_request_actions and found the code for opening a Buy position. I got error 4756 and retcode 10030. I understood that 10030 - it is the OrderSend property, but I have not understood how this property should be used (I looked at somebody else's code) and what it is mainly used for. Then I openedhttps://www.mql5.com/ru/docs/trading/ordersend, copied the code, ran it, it worked fine.
But I still don't understand why error 4756 appears and how to get rid of it, as well as 10030.

Looked at the code between

and this one.

They seem almost identical to me, I don't see where these errors appear (4756 and 10030). Point the finger and explain please

One field in the structure is not filled in. And it ' s not enough, but it's not such an error.

Instant Execution

A trade order to open a position in the Instant Execution mode (the mode of trading at streaming prices). 9 fields are required:

  • action
  • symbol
  • volume
  • price
  • sl
  • tp
  • deviation
  • type
  • type_filling

You can also specify magic and comment fields.

Market Execution

A trade order to open a position in the Market Execution mode. Requires 5 fields to be specified:

  • action
  • symbol
  • volume
  • type
  • type_filling

You can also specify magic and comment fields.


 

what update has arrived, 1736, what's in it, where can I read it?

 

I propose to give an opportunity to determine programmatically which indicator buffer is drawing on the chart.

Suppose a trader starts his own indicators, we don't know how many buffers are used for calculation and how many are used to draw the indicator on the chart.

Addressing custom indicators through

intChartIndicatorGet(
longchart_id,// chart identifier
intsub_window// number of the subwindow
const string indicator_shortname // short indicator name
);


We can also request the array of drawing buffers

intChartIndicatorGet(
longchart_id,// chart identifier
intsub_window//window number
const string indicator_shortname // short indicator name

int & IndicatorVisualBuffer[] // drawing buffer numbers... );


This will extend the possibility of working with unknown indicators installed on the chart...

 
Vladimir Pastushak:

I propose to give an opportunity to determine programmatically which indicator buffer is drawing on the chart.

Suppose a trader starts his indicators, we don't know how many buffers are used to calculate and how many are used to draw the indicator on the chart.

Addressing to the indicator through

intChartIndicatorGet(
longchart_id,// chart ID
intsub_window// number of the subwindow
const string indicator_shortname // short indicator name
);


We can also request the drawing buffers array

intChartIndicatorGet(
longchart_id,// chart identifier
intsub_window//window number
const string indicator_shortname // short indicator name

int & IndicatorVisualBuffer[] // drawing buffer numbers... );


This will increase the possibility of working with unknown indicators installed on the chart...

What does it return?

int  ChartIndicatorGet(
   long           chart_id,              // идентификатор графика
   int            sub_window             // номер подокна
   const string   indicator_shortname    // короткое имя индикатора
   );

and what will be the use of adding it? You want to add an input parameter and receive the same indicator handle in response...

And if you don't mind, for what purpose is it needed? I am not being ironic. After all, if something is suggested, you should, in my opinion, give a convincing argument of the necessity of the suggested.

 
Alexey Viktorov:

What does it return

and what good would it do to add it? You propose to add an input parameter and get the same indicator handle in response...

And if it isn't difficult, for what purposes did such a necessity appear? The question is without irony. After all, if something is offered, it is necessary, in my opinion, to give convincing arguments in necessity of the offered.


The user puts any indicator.

The Expert Advisor automatically finds it and uses buffer data to receive the signal.


Now we have to use iCustom and if we can write the parameter list, here is the problem with buffers....

It is possible to count the buffers quantity through Copy, but it's impossible to understand which one of them is drawing ...

 
Vladimir Pastushak:

The user places any indicator.

The Expert Advisor automatically finds it and uses buffer data to obtain the signal.


Now we have to use iCustom and if we can write the list of parameters, here is the problem with buffers....

It is possible to count the buffers quantity using Copy programmatically, but it's impossible to understand which one of them is drawing ...

Why is it impossible? Can the buffer INDICATOR_CALCULATIONS be taken out through iCustom()?

It's an interesting question, but not in this thread to discuss it. I personally have doubts that it can somehow improve or simplify the programmer's work. The indicators are too different and the conditions of their application are too different. Then we will have to ask to be able to determine the type of graphical plotting and some other things, and our internal requests will snowball.

 
Alexey Viktorov:

Why is it not possible? Can the INDICATOR_CALCULATIONS buffer be reached through iCustom()?

The question is interesting, but not in this thread to discuss it. Personally I have doubts that it can somehow improve or facilitate the programmer's work. There are too different indicators and too different conditions for their application. Then we will have to ask to be able to determine the type of graphical plotting and some other things, and our internal requests will snowball.


Theoretically, what is written into the indicator by default, I'm not speaking about the programmer's code, should be available from outside ... Buffers their number, plotting type, colour, and other standard ...

 

This is the problem I've encountered:

I decided to use as magic the remainder of division of ChartID by 1000 or 10000, it doesn't really matter.

But for some reason with different ChartID() the remainder of the division suddenly turns out the same. Question: why?

Checking script

/********************Script program start function*******************/
void OnStart()
{
  long chartID = ChartID(), d = 100000;
  Print("ChartID - ", ChartID());
  Print("fmod(ChartID(), ",  d, ") = ", fmod(ChartID(), d));
}/*******************************************************************/

Result

2018.01.15 13:01:45.881 Script 00 EURUSD,M15: removed
2018.01.15 13:01:45.881 00 EURUSD,M15: uninit reason 0
2018.01.15 13:01:45.881 00 EURUSD,M15: fmod(ChartID(), 100000) = 74912
2018.01.15 13:01:45.881 00 EURUSD,M15: ChartID - 131472503841474907
2018.01.15 13:01:45.881 00 EURUSD,M15: initialized
2018.01.15 13:01:45.871 Script Test\00 EURUSD,M15: loaded successfully
2018.01.15 13:01:40.361 Script 00 EURUSD,H1: removed
2018.01.15 13:01:40.361 00 EURUSD,H1: uninit reason 0
2018.01.15 13:01:40.361 00 EURUSD,H1: fmod(ChartID(), 100000) = 74912
2018.01.15 13:01:40.361 00 EURUSD,H1: ChartID - 131472503841474908
2018.01.15 13:01:40.361 00 EURUSD,H1: initialized
2018.01.15 13:01:40.351 Script Test\00 EURUSD,H1: loaded successfully

I expected to see 74907 and 74908 respectively, because the remainder of the division should be the same.


I am also waiting for an answer to this question.

Forum on trading, automated trading systems and strategy testing

Bugs, bugs, questions

Alexey Viktorov, 2018.01.09 14:21

In the MT5 tester the "Input field" object OBJ_EDIT doesn't allow to edit value in it. Is this the way it's designed or is it a bug?

In terminals and MT4 tester it is editable, but in MT5 tester it doesn't want to, the value entered into it programmatically when creating the object disappears at all.


 
Alexey Viktorov:

But for some reason different ChartID() suddenly produces the same residual from division. Question: why?

Because input fmod is double. Double cannot store a huge number of integers. For instance, this is your case:

Print(DoubleToString((double)131472503841474907, 0)); // 131472503841474912

Do this.

long fmod( const long Value, const long Value2 )
{
  return(Value % Value2);
}


Using float as an example, you can quickly understand the peculiarity of double

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{
  for (int i = 0; i < INT_MAX; i++)
    if ((int)(float)i != i)
    {
      PRINT(i);
      PRINT((float)i);
      PRINT((double)i);
      
      break;
    }
}


Result

i = 16777217
(float)i = 16777216.0
(double)i = 16777217.0


SZY double doesn't lose the information of the whole int-range, not so with long.

 
fxsaber:

Because the input fmod is double. Double cannot store a huge number of integers. For example, your case:

Do this.

Of course, I will check this sample now but I also had a check code like this

/********************Script program start function*******************/
void OnStart()
{
  long chartID = ChartID(), d=100000;
  Print("ChartID - ", ChartID());
  Print("fmod(ChartID(), ",  d, ") = ", fmod(ChartID(), d));
  printf("LONG_MAX = %I64d",LONG_MAX);
  printf("DBL_MAX = %.16e",DBL_MAX);
  Print("DBL_MAX-LONG_MAX = ", DBL_MAX-LONG_MAX);
}/*******************************************************************/

the result is

2018.01.15 14:07:20.440 Script 00 EURUSD,M15: removed
2018.01.15 14:07:20.440 00 EURUSD,M15: uninit reason 0
2018.01.15 14:07:20.440 00 EURUSD,M15: DBL_MAX-LONG_MAX = 17976931348623157081452742373170435679807 0567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368
2018.01.15 14:07:20.440 00 EURUSD,M15: DBL_MAX = 1.7976931348623157 e+308
2018.01.15 14:07:20.440 00 EURUSD,M15: LONG_MAX = 9223372036854775807
2018.01.15 14:07:20.440 00 EURUSD,M15: fmod(ChartID(), 100000) = 74912
2018.01.15 14:07:20.440 00 EURUSD,M15: ChartID - 131472503841474907
2018.01.15 14:07:20.440 00 EURUSD,M15: initialized
2018.01.15 14:07:20.430 Script Test\00 EURUSD,M15: loaded successfully

It indicates that there should not be value truncation.


But here I checked this variant and slightly changed the proposed

/********************Script program start function*******************/
void OnStart()
{
  long chartID = ChartID(), d=100000;
  Print("ChartID - ", ChartID());
  Print("fmod(ChartID(), ",  d, ") = ", (long)fmod(ChartID(), d));
  Print("ChartID() % ", d, " = ", ChartID() % d);
}/*******************************************************************/

and got the expected variant.

2018.01.15 14:17:51.301 Script 00 EURUSD,M15: removed
2018.01.15 14:17:51.301 00 EURUSD,M15: uninit reason 0
2018.01.15 14:17:51.301 00 EURUSD,M15: ChartID() % 100000 = 74907
2018.01.15 14:17:51.301 00 EURUSD,M15: fmod(ChartID(), 100000) = 74912
2018.01.15 14:17:51.301 00 EURUSD,M15: ChartID - 131472503841474907
2018.01.15 14:17:51.301 00 EURUSD,M15: initialized
2018.01.15 14:17:51.291 Script Test\00 EURUSD,M15: loaded successfully

Another question appears,

If MathMod as well as fmodreturns real remainder after division of two numbers. And % according to the documentation

The remainder of minutes = time % 60;


why is there a difference?