A newcomer asks! - page 23

 
Михаил:
long is a variable type, but I repeat that it is not right.

PositionGetInteger() returns long type. You don't need to bother with such long types likeENUM_POSITION_TYPE.

Anyway, the programmer performs one type conversion. You'd better write it shorter.

They give advice to novice programmers here...

 

Nextor257:

...

Why is (long) specified before POSITION_TYPE_BUY ?

...

This is a change of type by a variable on the fly.

 
Dmitry Fedoseev:

PositionGetInteger() returns long type. You don't need to bother with such long types likeENUM_POSITION_TYPE.

Anyway, the programmer performs one type conversion. You'd better write it shorter.

They give advice to beginners here...

Wrong, because after that the comparison is done:

 if(type==(long)POSITION_TYPE_BUY

And POSITION_TYPE is not long, but

ENUM_POSITION_TYPE

Identifier

Description

POSITION_TYPE_BUY

Buy

POSITION_TYPE_SELL

Sell

 
Михаил:

Wrong, because then comes the comparison:

And POSITION_TYPE is not long, but

ENUM_POSITION_TYPE

Identifier

Description

POSITION_TYPE_BUY

Buy

POSITION_TYPE_SELL

Sell

Yeah... you have a very deep knowledge of programming.
 
Dmitry Fedoseev:
Yep... you have very deep knowledge in programming.

You don't seem to have any knowledge at all - just ambition!

ENUM_POSITION_PROPERTY_INTEGER

Identifier

Description

Type

POSITION_TIME

Position opening time

datetime

POSITION_TIME_MSC

Position opening time in milliseconds from 01.01.1970

long

POSITION_TIME_UPDATE

Time of position change in seconds since 01.01.1970

long

POSITION_TIME_UPDATE_MSC

Time of position change in milliseconds since 01.01.1970

long

POSITION_TYPE

Type of position

ENUM_POSITION_TYPE

POSITION_MAGIC

Magic number for the position (see ORDER_MAGIC)

long

POSITION_IDENTIFIER

The position identifier is a unique number, which is assigned to each newly opened position and remains unchanged throughout its life. Reversal of a position does not change the position identifier.

long

 
Михаил:

You seem to have no knowledge at all - just ambition!

ENUM_POSITION_PROPERTY_INTEGER

Identifier

Description

Type

POSITION_TIME

Position opening time

datetime

POSITION_TIME_MSC

Position opening time in milliseconds from 01.01.1970

long

POSITION_TIME_UPDATE

Time of position change in seconds since 01.01.1970

long

POSITION_TIME_UPDATE_MSC

Time of position change in milliseconds since 01.01.1970

long

POSITION_TYPE

Type of position

ENUM_POSITION_TYPE

POSITION_MAGIC

Magic number for the position (see ORDER_MAGIC)

long

POSITION_IDENTIFIER

The position identifier is a unique number, which is assigned to each newly opened position and remains unchanged throughout its life. Reversal of a position does not change the position identifier.

long

For the PositionGetDouble() function

This is the case that people say: "when you look in the book, you see a figurine".

Try to compile it first:

ENUM_POSITION_TYPE z=PositionGetInteger(POSITION_TYPE);

There will be a warning.

One function cannot produce different types in different cases. It will be long in any case. And did you believe that the same function returns different types? Yes... No one is surprised by superstitions on this forum, it's normal...

ENUM_POSITION_TYPE in the type column means that all possible return values are in the corresponding enumerator.

It would also help to pay more attention, the table above refers to PositionGetInteger(), and the PositionGetDouble() written below has nothing to do with it at all.

 

I wonder who sees the "figure" ....

I wrote it this way:

ENUM_POSITION_TYPE pos_type = ENUM_POSITION_TYPE(PositionGetInteger(POSITION_TYPE));
 
Dmitry Fedoseev:

This is a change of type change on the fly.

Thank you very much.
 
Михаил:

I wonder who sees the "figure" ....

I wrote it like this:

ENUM_POSITION_TYPE pos_type = ENUM_POSITION_TYPE(PositionGetInteger(POSITION_TYPE));

Why write ENUM_POSITION_TYPE before the PositionGetInteger? Because, according to your belief, the PositionGetInteger function with the identifier POSITION_TYPE already returns the type ENUM_POSITION_TYPE.

 
Dmitry Fedoseev:

Why write ENUM_POSITION_TYPE before PositionGetInteger? Because, according to your belief, the PositionGetInteger function with identifier POSITION_TYPE already returns the ENUM_POSITION_TYPE type.

You are the Guru of programming - go answer it yourself....

And this is not my "belief", but the documentation...

But I think thePositionGetInteger() functionalways returns the value of the LONG type and it doesn't matter what was "inside" INTRGER or LONG.

The developers did it to avoid writing two functions.

Therefore, to get the position type(and it is INTEGER) it is correct to do as I wrote:

ENUM_POSITION_TYPE pos_type = ENUM_POSITION_TYPE(PositionGetInteger(POSITION_TYPE));