[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 41

 

Good day to all, again!

Question is, why does the function (see below) give an error: 'A' - array item cannot be assigned?

double get_init_values(double A[], int index){

int size = 0;

size = ArraySize(A);

if (size < index){

return (0);

}else{

A [index] = Ask;

return (A);
}

}

Please have a look at it!

Thanks in advance!
 
BBSL:

Good day to all, again!

Question is, why does the function (see below) give an error: 'A' - array item cannot be assigned?

Please have a look at it!

Thanks in advance!

An array cannot be returned
 
granit77:
You don't have to try! The .mqh files are placed in include and lie quietly. When compiling the EA in which they are written, the compiler automatically combines the necessary code elements and compiles them together.
When you try to separately compile .mqh, the compiler tries to determine the type of the product (Expert Advisor, indicator...) and starts to ask "where have you started?
You should start figuring out .mqh if errors occur during proper compilation.

Thanks!
 
DhP:

Your line is as valid as the first.

This way you can get any information about an open order,

but only once at the time of opening confirmation.

See https://docs.mql4.com/ru/trading/OrderSe nd

Thanks for the reply and the useful link.
 

Question for indicator writers.

How to impose MA on an indicator that outputs data from three buffers in a row in the indicator code.

I can get MA from one buffer.

 
Vinin:

You can't return an array


Thank you for answering!

Why is there no compile-time error here?

double get_init_Array(double A[], int size){

ArrayResize(A, size);

ArrayInitialize(A, 0);

return (A);

}

Or am I not returning an array here?

Is there any way to return a pointer to the first array element, like in c++?

Thank you in advance!

 

People, who knows why in the test in all ticks mode the EA loses, but in the bar opening mode it does very well?

Does it mean that if I only consider bar openings the EA will trade well?

 
BBSL:


Thank you for replying!

Why is there no compile-time error here?

Or am I not returning an array here?

Is there any way to return a pointer to the first element of an array, like in c++?

Thanks in advance!

If you want some array to be filled in the function, pass in a reference

double get_init_Array(double & A[], int size)

If you just want the first element to be returned

then

return (A[0]);
 
r.ig.h:

People, who knows why in the test in all ticks mode the EA loses, but in the bar opening mode it does very well?

Does it mean that if I only consider bar openings the EA will trade well?

No. In the "open prices" mode the Expert Advisor "triggers" your stops and pending orders retroactively.
 
Sergey_Rogozin:

Question for indicator writers.

How to impose MA on an indicator that outputs data from three buffers in a row in the indicator code.

I can get MA from one buffer.

what is "alternating" ?
Reason: