Questions from a "dummy" - page 111

 
openlive:

Now it's giving me...

2012.02.26 15:47:46 Tester file C:\Users\openlive\AppData\Roaming\MetaQuotes\Terminal\9C3619DDD286B60B1DB9B9989A2FFC701\MQL5\Files\signal10000.csv open error [32]

First, check what you have in the folder C:\Users\openlive\AppData\Roaming\MetaQuotes\Terminal\9C3619DDD286B60B1DB9B989A2FFC701\MQL5Files\

Second: there is no error 32 in MQL5. Strange... Do you check the handle after trying to open the file and the last error code after trying to open it?

 
DenisR:
What is "math mode"?
In the math calculations mode there are no history runs - due to this the maximum speed is achieved when you need to make math calculations without using trading operations. In this mode, if you optimize a trading Expert Advisor, you will have to model the market environment (history data, spread, etc.) on your own. In this case, you can use any historical data, take it from a pre-prepared file.
 
DenisR:
What is "math calculations mode"?

In this mode, only OnTester() is called; however, the complexity and volume of calculations in OnTester() is not limited. If you calculate your Expert Advisor's profit for the given input parameters, you can use the tester's genetic algorithm for optimization.
 

Please help me understand, my brain is boiling.

1. I understand that switching to x64 OS is connected with the fact that it is impossible to "partition" more than 4 GB of RAM on 4 bytes. I have the x64 OS, why do the pointers occupy 4 bytes (it concerns not only mql, but C++ as well))?

2. Question about MT4: why when I call dll function:

#import "MemoryDLL.dll"
void fn(double j[]);           // Подозреваю что так отдается адрес?
#import

int start()
{
   double dVal[1];
   fn(dVal);
   retutn(0);
} 

The dll variable can be taken normally in these variants:

extern "C" __declspec(dllexport) void fn(double &j);       // Почему так работает????
// и так
extern "C" __declspec(dllexport) void fn(double *j);       // Думаю что должно работать только так

Although I assume that pointer and reference, by idea should not be compatible, for example because the pointer to double takes 4 bytes in my case.

It works like this:

#import "MemoryDLL.dll"
void fn(double j);           
#import
                                                  // Согласен

extern "C" __declspec(dllexport) void fn(double j);  

Doesn't work:

#import "MemoryDLL.dll"
void fn(double j);           
#import
                                                  // Почему нет???

extern "C" __declspec(dllexport) void fn(double &j);  

At least how would it work (I want to pass multiple arrays)? I don't want to do it via backtracking.

 
220Volt:

At least how to do it correctly (I want to pass several arrays)? Because I don't want to go through the backdoor.

And in MQL, who will put & in the function declaration?
 
sergeev:
And in MQL, who will put & in function declaration?

Yes, that would probably be the right thing to do. But it's not like MQL works in C anyway (I could be wrong).

 
220Volt:

Yes, that would probably be the right thing to do. Only MKL doesn't work somehow by C anyway (I can be wrong).

there is one difference in passing - everything needs to be passed only by reference &, by pointer ' * ' only class objects can be passed

 

I thought that an elementary memory area consists of two parts - an address and a value. If an address is transmitted, it must be in some variable with the address of the area being transmitted in the "value" field. That's why I don't understand how such variants can work correctly at the same time:

extern "C" __declspec(dllexport) void fn(double &j);  
// и так
extern "C" __declspec(dllexport) void fn(double *j);  
// Прототип для MQL - void fn(&s[]);

We can try to find an explanation such as - it is transferred memory area "as is" and the receiving side decides what to do with it (to write the address to the value or copy the address). But this hypothesis is destroyed by the fact that it does not work this way:

extern "C" __declspec(dllexport) void fn(double j);  

// Прототип для MQL - void fn(&s[]);

One could again try to find an explanation - in the first duplicates, the address in the "value" field is given as input, and the receiving side decides what to do with it. In contrast to this, the fact that in C++ the compiler says not to do so, in its opinion or so:

fn(int *x)
{
}

int i;
fn(&i);

or this:

fn(int &x)
{
}

int i;
fn(i); 
All in all, I see nothing but contradictions.
 

You ask, I'll answer.

I've come to the conclusion that a link and a pointer are essentially the same thing. There are slight differences:

  • You can write an address into a reference only once, into a pointer many times.
  • Different syntax

A very important point is: if the called function has a reference or a pointer as an argument, the address is actually passed. This is very important to understand when calling from dll.

 

Can you tell me how to find the exact value of the crossing of the main line and the indicator line of the stochastic?

Visually it's easy, but how to implement it programmatically?

Reason: