Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 450

 
Juer:

And I have several fields of the same type. I don't think that's going to help.

I found thishttps://www.mql5.com/ru/code/16282

I decided to pass its address (offset) in bytes instead of field name.

I see. You don't seem to have a full understanding of what you have and what you want to get.

 
Juer:

Or tell me, how can I get a structure field knowing its string name?

here i have a value

string field="dval";

I want to query this particular structure field.

There are no variable names in the translated program. Address reference. and you can, for example, like this.

test x; if(number=1) y=x.num; or if(name="num") y=x.num; Byte-by-byte access to the structure is also an option

 

Can you tell me how to find the ratio of 2 time periods? (I need a ratio of bars between 2 periods)
I wrote it like this, but it gives 0. Time1>Time>Time3 always

Tried without explicit type conversion, and (double) tried to write

(int)(Time1-Time2)/(int)(Time2-Time3)
 
Roman Sharanov:

Can you tell me how to find ratio of 2 time periods?
I wrote it like this, but it gives 0. Time1>Time>Time3 always

tried without explicit type conversion, and (double) tried to write



and what is Time1?

 
Vladislav Andruschenko:



What is Time1?

This is where the time value is stored, like the other variables

 
Roman Sharanov:

This is where the time value is stored, like the other variables

Maybe datetime instead of double?
 
Vladislav Andruschenko:
How about datetime instead of double?

Where do I write this? I don't really understand.

 
Roman Sharanov:

Can you tell me how to find the ratio of 2 time periods? (I need a ratio of bars between 2 periods)
I wrote it like this, but it gives 0. Time1>Time>Time3 always

Tried without explicit type conversion, and (double) tried to write

(double)(Time1-Time2)/(double)(Time2-Time3)
 
Could you please tell me how to calculate the loss or profit when closing counter orders? There are sell 1.23615 and buy 1.24915, the price is at Ask 1.24583. Is there any formula?
 
Taras Slobodyanik:

Said he had tried it that way before, nothing

Reason: