Does anyone know if TICK_FLAG can have a larger value of 252? - page 2

 
fxsaber:


Result

                          tickflag -= tickflag & TICK_FLAG_##A; 
                         tickflag &= ~TICK_FLAG_##A; // turn-off that bit

The flags structure member in MqlTick  is a 32 bits number. So, it can encode up to 32 different flags as a  bit-field.

#define flag_0  1           // 2^0   -> 1
#define flag_1  1 << 1      // 2^1   -> 2
#define flag_2  1 << 2      // 2^2   -> 4
#define flag_3  1 << 3      // 2^3   -> 8
#define flag_4  1 << 4      // 2^4   -> 16
#define flag_5  1 << 5      // 2^5   -> 32
#define flag_6  1 << 6      // 2^6   -> 64
#define flag_7  1 << 7      // 2^7   -> 128
#define flag_8  1 << 8      // 2^8   -> 256


Each flag is specific to one bit from position 0 to position 31. This facilitate to combine (encode) multiple binary attributes into  a single number by using simple arithmetic + or bitwise | (or) operators.

The rest of the bit-field is unused or it may be used for adding new attributes in future releases.

tick.flags = flag_0 + flag_4    // 1 + 16 = 17
tick.flags = flag_0 | flag_4    // 1 | 16 = 17

The bit at position 7 may indicate that a change has occurred in some flags, i think.

'

 

Hi, sorry for double post.

The additional bit number 8 seems to change the behavior of the Strategy Tester when using "Real Ticks".

According to this documents https://www.mql5.com/en/docs/runtime/testing#real_ticks, the tester can change the "Rates" value if it diverges from the "Tick" value in case of "Real Ticks" test.    For example, if the "Rates" PRICE_OPEN diverges from the tick[0].last in a given minute "Rates", the Strategy Tester ignores the original "Rates", replacing the original "Rates" with a calculated "Rates" with PRICE_OPEN equal to the tick[0].last at that minute.

If the Tick has the flag of bit 8 (value 256), it seems that this divergence correction does not occur.

That seems useful.

But there is a problem when used with custom symbol, because the CustomTicksReplace() command does not apply bit number 8 to the custom symbol Flag, which is created only with the previous bits on Flags.

This behavior occurs only in the Strategy Tester, who makes corrections on bars by divergence of tick when testing "Real Ticks" mode.

When using Scripts - OnStart () - the behavior does not occur.

MetaCotes could create the option of not correcting bars for the Tester "Real TIcks" mode. Or allow CopyTicksReplace() to copy Flag bit number 8.


Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
The idea of automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
Keith Watford:

I have merged the answers from the 2 topics.

Thanks for wasting mine and others' time by selfishly posting the same question twice. (sarcasm)

Sorry for this.

Reason: