Questions from a "dummy" - page 236

 
Is it possible to pass an array to a function that does not start with a zero element? For example, as a reference to the i-th element, and how would that look?
 
fellow:
Is it possible to pass an array to a function that doesn't start with a zero element? For example, as a reference to the i-th element, and how would this look?

you can

winapi memcpy, etc. to help.

 
fellow:
is it possible to pass an array to a function that doesn't start with a zero element? For example, as a reference to the i-th element, and how would that look?

You do not declare an array in the function import, but a simple reference.

When calling the function, pass in the i-th element of the array as a parameter. If you want an array from the beginning, pass in the 0th element of the array as a parameter.

Approximately like this:

#import "MyDLL.dll"
   void MyFunc(int& par1, int size);
#import
...
   int IntArray[100];
   int i;
...
   MyFunc(IntArray[0],100);
...
   i=55;
   MyFunc(IntArray[i],ArraySize(IntArray)-i);
...
Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - Документация по MQL5
 
stringo:

This is about right:

Well, it doesn't work in 4 because the index element is not a lvalue when passed to the function.

It works in 5.

 
TheXpert:
Well, this will not work in 4 because the index element is not a lvalue when passed to the function
I did not understand that we are talking about 4
 
stringo:
I didn't realise we were talking about a four.
Nah, I just thought the 5 had the same thing. Checked it out, it's fine here.
 

So these examples are for an external library? And without DLL ?

winapi memcpy does not belong to mql5 either

 
fellow:

So these examples are for an external library? And without DLL ?

winapi memcpy does not belong to mql5 either

no, well if you put queries outside the scope of mql, that's what you get.
 
fellow:

So these examples are for an external library? And without DLL ?

winapi memcpy does not belong to mql5 either

If without DLL, then you need to pass the start index in addition to the array
 

Good morning!

A word of advice to a very novice))). The question is as follows:

Let's assume a position was opened by a price jump and an ascending MA (it was set in the code), but almost immediately the chart changed, that is, the MA started going down (as well as the entire chart of course)) ). I have to write a function that will close the position at this point, but I have not reached stop loss or limit and reopen the position with the new data. And it all has to be checked each time. I hope the description is clear:)))

Reason: