Errors, bugs, questions - page 94

 
vdv2001:

I encountered such a problem, an acquaintance asked me to write an expert to check the TS functionality. I thought I would write it in Five (it's more convenient to write it + debugger). I wrote, got the result:

I think it's good, I can rewrite it for 4.

I have rewritten it 1:1. This TS has no indicators, only time and price range. The result surprised me a lot:

The testing period is from 1.01.2000 to today.

I wonder which tester shows the right result?

The number of trades is very large, so the question about spreads arises - are they the same for both tests?

 

How do I assign a value to a two-dimensional array? I'm writing like this:

positions[j, 0]=PositionGetInteger(POSITION_MAGIC);

The result is an error: ',' - unexpected token''.


 
EvgeTrofi:

How do I assign a value to a two-dimensional array? I'm writing like this:

The result is an error: ',' - unexpected token'.


Make it like this:

   double array[2][4];
   array[1][0]=5;
PS. There are examples of array declarations in the help.
 

How do I correctly translate one data type to another?

For example, round up a floating point value and transfer it to a variable with an integer data type.

When trying to do this:

   double Close = iCloseMQL4(Symbol(),Period(), 1);
   double Open =  iOpenMQL4(Symbol(),Period(), 1);
   int Midle=MathRound(MathAbs(Close-Open)/_Point);

On the last line of the compile, a warning appears:"possible loss of data due to type conversion".

Is there any way to avoid it?

 
Rosh:

Make it so:

PS. There are examples of array declarations in the help.
Thank you! It worked. But it's exactly the same line in the help
array[1][0]=5;
I couldn't find!
 
EvgeTrofi:
Thank you! It works. But I couldn't find such a string in the help!

It may not be written head-on, but there is an example of declaring a multidimensional array, and there is an example in the text of referring to an array element:

Arrays

An array is an indexed collection of identical data:

int a[50]; // A one-dimensional array of 50 integ ers.
double m[7][50];// A two-dimensional array of seven arrays,
// each consisting of 50 numbers.
MyTime t[100];// array containing elements of MyTime type

An array index can only be an integer. No more than four-dimensional arrays are allowed. The elements of an array are numbered starting with 0. The last element of a one-dimensional array is numbered 1 less than the array size, i.e. accessing the last element of an array of 50 integers will look like a[49]. The same is true for multidimensional arrays - one dimension is indexed from 0 to dimension size-1. The last element of the two-dimensional array from the example will look like m[6][49].

 
EvgeTrofi:

How do I correctly translate one data type to another?

For example, round up a floating point value and transfer it to a variable with an integer data type.

When trying to do this:

There is a warning on the last line when compiling:

Is there any way to avoid it?

Yes, do an explicit type conversion.
Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Основы языка / Типы данных / Приведение типов - Документация по MQL5
 
Thank you! figured it out!!! :)
 
Rosh:

The number of trades is very high, so the question arises about the spreads - are they the same for both tests?

EURJPY currency pair in Five test according to your data.

Four is Alpari, the minute data was downloaded from your server via Quote Archive -> Download.

Obviously there is a difference in spreads, but the result is very different.

For 2500 trades the difference should be at most 2500$-5000$ but it is 10000$, as they say don't believe your eyes.

By the way there is 1 trade a day on condition of a profit of not less than 8 (80 - five digits) pips.

 
How do I change my email in my profile?
Reason: