Questions from Beginners MQL5 MT5 MetaTrader 5 - page 456

 
E_Ghazaryan:
Yeah, right =D )))) Already attached.)))

All these parameters should be listed after comma in iCustom() after the indicator name, and after them two more parameters: buffer number and bar number, from which the data is taken. I.e:

iCustom(Symbol(), Period(), "_MTF_ADX3", 0, 500, 6, 6, 8, 14, 6, 6, 2, true, false, buffer_number, bar_number).

All the listed values can be set by external variables of the EA and the names of these variables can be written into iCustom() instead of the hardcoded values.

 

Can you tell me why:

double d = 0.07;

d = NormalizeDouble(d,2);

in both cases d== 0.07000000000000001

how do I leave 2 decimal places?

 
pusheax:

Can you tell me why:

double d = 0.07;

d = NormalizeDouble(d,2);

in both cases d== 0.07000000000000001

how to leave 2 decimal places?


Note that when output to Journal using Print(), a normalized number may contain a larger number of decimal places than you expect. For example,

   double a=76.671;             // нормализованное число с 3 знаками после запятой
   Print("Print(76.671)=",a);   // выведем его как есть
   Print("DoubleToString(a,8)=",DoubleToString(a,8)); // выведем с заданной точностью

will be output in the terminal:

  DoubleToString(a,8)=76.67100000

  Print(76.671)=76.67100000000001


That is, for printing the output of extra values is not a problem.

Документация по MQL5: Преобразование данных / NormalizeDouble
Документация по MQL5: Преобразование данных / NormalizeDouble
  • www.mql5.com
Преобразование данных / NormalizeDouble - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Karputov Vladimir:


Note that the normalised number when output to the logbook using Print() may contain more decimal places than you expect. For example,

will be output in the terminal:


So, for printing, outputting extra values is not a problem.

Thank you, it's just when I try to open a position with 0.07 lot it displays error (I thought it's the reason), so I will try to find out more.
 
pusheax:
Thank you, it's just that when I try to open a position with 0.07 lot it gives an error (I thought that's the problem), it must be something else, I'll look into it further.
The first thing to do is to look at the description of the error number. This will shorten the search path.
 

good evening

I have declared a dynamic array

double all_order[][10];

I redefined in OnInit

ArrayResize(all_order, 20);

I enter data into the function

void OR_spisok(double a0, double a1, double a2, double a3, double a4, double a5)

{

int a10=int(a0);

all_order[a10][0]=a0;

all_order[a10][1]=a1;

all_order[a10][2]=a2;

all_order[a10][3]=a3;

all_order[a10][4]=a4;

all_order[a10][5]=a5;

}

three lines works fine, on 4 it clinches

2015.10.09 20:13:47.908 3102 EURUSD,H1: array out of range in '3102.mq4' (393,10)

393,10 it is:

all_order[a10][0]=a0;

what is wrong?

Removed line#property strict

The script works, can I continue without this line?

 
pr0gre5:

good evening

declared a dynamic array


Removed the#property strict line

The script works, can I continue without this line?

Yes
 
Artyom Trishkin:

All these parameters should be listed after comma in iCustom() after the indicator name, and after them two more parameters: buffer number and bar number, from which the data is taken. I.e:

iCustom(Symbol(), Period(), "_MTF_ADX3", 0, 500, 6, 6, 8, 14, 6, 6, 2, true, false, buffer_number, bar_number).

All listed values can be set by external EA variables and write names of these variables to iCustom() instead of hardcoded values.

Thank you for your reply. But the fact is that I did so at first, but when I received wrong values, I decided to remove the parameters from iCustom, for the Expert Advisor to use the standard parameters of the indicator. In both cases, however, EA gets wrong values. For example, Alert gives 30.32362 for the Blue line, but when I look at the indicator chart it has 22.3320 in the same place. And the same with other lines.
 
E_Ghazaryan:
Thanks for the reply. But the thing is, I did so at first, but when I got wrong values, I decided to remove the parameters from iCustom so the EA would use the standard indicator parameters. However, in both cases, the Expert Advisor receives wrong values. For example, Alert gives 30.32362 for the Blue line, but when I look at the indicator chart it has 22.3320 in the same place. And the same with the other lines.
Show me the code where you take the data from the indicator.
 
Artyom Trishkin:
Show me the code where you take data from the indicator.

The code was big. But to find out what the problem is, the Expert Advisor does not work by the rules, I cut this part into a separate one and started to test it.

double Ind_Blue=iCustom(NULL, 0, "_MTF_ADX3",1,0);

double Ind_Red=iCustom(NULL, 0, "_MTF_ADX3",2,0);

Alert(" Ind_Blue= " , Ind_Blue , " Ind_Red= " , Ind_Red);

I am also attaching the Expert Advisor file. I don't want to waste your time, but I can't find the problem.

And there is a similar indicator with the same problem (Adx mtf). I have an mq4 file for it. But there seems to be no problem in the code.

Files:
_MTF_ADX3.ex4  5 kb
Adx_mtf.ex4  21 kb
Adx_mtf.mq4  6 kb
Reason: