Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1074

 
Artyom Trishkin:

And you print out the numerical values of the flags. The total flag should contain all the values of the desired flags. And what does OBJ_PERIOD_H3-1 equal? If the sum of all flags up to it, then yes, but if not, then there's a bug somewhere.

Nah... I was chatting about flags in a thread the other day and experimenting with lines like this

Print("summa_flag = ", 1 | 2 | 4);

it adds up to 7

а

Print("summa_flag = ", 1 | 2 | 3);

it only gives 3.


Added:

Look, flag 4... the sum before it is 3.

Flag 16... the sum before it is 15.

And so on.

 
Alexey Viktorov:

Nah... I was chatting about flags in a thread the other day and experimenting with lines like this

it adds up to 7

а

gives only 3

Naturally. That's right there.

Each successive flag has, must have a value twice that of the previous one.

And by entering 3 instead of 4, you have duplicated the first two flags: 1 and 2
 
Alexey Viktorov:
Of course it is. Just one short line. Just need to determine which is the oldest TF in the list of flags.

It works for us! A great solution!

 
Anzhela Sityaeva:

It works for us! Great solution!

This is only if you want everything to be visible BEFORE the highest timeframe. As soon as you want to remove any of those before the oldest one, it won't work with such a design.

ZS, I'm sorry, is "you", "we", "our majesty"?

 
Artyom Trishkin:

This is only if you want everything to be visible BEFORE the most senior timeframe. As soon as you want to remove any of those that are before the most senior, nothing will work with such a construction.

Artem, everything will work out.

For example, you need to display all the lower ones except M15...

Then it will be.

ObjectSetInteger(ch_id, name, OBJPROP_TIMEFRAMES, OBJ_PERIOD_H3-1-OBJ_PERIOD_M15);
 
Alexey Viktorov:

Artem, everything will work out.

For example, you need to display all the lower ones except M15...

That would be...

So... what I'm saying is...

Continue - and show what happens if you need to display all highs up to and including W1 and one low...

 
Artyom Trishkin:

ZS, I'm sorry, is 'you', 'we', 'our majesty'?

YES. There are two of us.))

 
Alexey Viktorov:

YES. There are two of us, after all.))

You're confusing your second 'we' - you've shown a way that works in one situation only - only when you need to display EVERYTHING: from, and to..., and no more.

And then there is a loss of flexibility, and again you have to list, but already unnecessary flags

 
Artyom Trishkin:

This is only if you want everything to be visible BEFORE the oldest timeframe. Once you want to remove any of those before the oldest, then nothing will work with such a design.

ZS, I'm sorry, is "you", "us" our majesty?

No, of course, it's just that I'm not the only one here, and most of the communication is on me... Partners are not fans of chat rooms etc....

 
Artyom Trishkin:

So... what I mean is...

Continue - and show what happens if we have to display all high ones up to and including W1 and one low one...

Clarify. I don't quite get it.

Artem, I dealt with the flags at your suggestion. And I recalculated all of them not only software, but also on a calculator. I assure you, everything will work. You just need to understand how much you need to subtract from which flag to leave only the flags you want.

Well calculate how much you have to subtract from 32 to leave the sum of flags 1|2|8.

In fact, flag 32 itself does not contain any of the listed flags. But if you subtract 1 from it, the sum of flags is 1|2|4|8|16 = 31

Hence if we have flag 32 that is not required, subtract 1 from it and subtract the sum of 4|16 from 31 and we will have only 1|2|8

Reason: