Strategy Tester: real_volume = 1 on bars of non-chart timeframes (regression between build 5833 and 6140)

Summary:

Since some build between 5833 and 6140, the Strategy Tester returns real_volume = 1 for bars of any timeframe other than the tested chart timeframe.
tick_volume is still correct, and so is history before the test start date. On the chart timeframe itself, real volume is correct. Build 5833 returns correct real volume for all timeframes.

This silently breaks every indicator/EA that uses real volume on a secondary timeframe (Force Index, MFI, Volumes, VWAP, etc. with VOLUME_REAL).

Environment:

- Symbol: WIN$N (B3 mini-index futures, XP Investimentos, XPMT5-DEMO). Same result with a custom symbol built from the same data.

- Tester: "1 minute OHLC". Same result with "Every tick" and "Every tick based on real ticks".

- Period: 2024.01.02 – 2024.01.06, deposit 3,000,000 BRL.

- OS: Windows 11 x64.


Steps to reproduce:

1. Compile the attached RealVolumeMTF_Repro.mq5. It reads the just-closed bar of InpTF (default M3) at every new InpTF bar via CopyRates / iRealVolume.

2. Test it on WIN$N with the chart timeframe = M1, InpTF = M3.

3. Repeat with the chart timeframe = M3.

4. Check the SUMMARY line in the Journal.


Results:

Build   Chart TF   Inspected TF   Closed bars   Bars with real_volume <= 1

--------------------------------------------------------------------------

5833    M1         M3             756           0 (CORRECT)

5833    M3         M3             756           0 (CORRECT)

6140    M1         M3             755           754 (BUG)

6182    M1         M3             756           754 (BUG)

6182    M3         M3             756           0 (CORRECT)

6230    M1 / D1    M3             —             same wrong behaviour (real_volume = 1)


Sample Journal output (same bars):

build 5833, chart M1:

WIN$N PERIOD_M3 bar 2024.01.02 09:03: tick_volume=32373 real_volume=100501 (iRealVolume=100501)

WIN$N PERIOD_M3 bar 2024.01.02 09:06: tick_volume=20077 real_volume=70428  (iRealVolume=70428)


build 6182, chart M1:

WIN$N PERIOD_M3 bar 2024.01.02 09:00: tick_volume=49744 real_volume=4434   (iRealVolume=4434)

WIN$N PERIOD_M3 bar 2024.01.02 09:03: tick_volume=32373 real_volume=1      (iRealVolume=1)

WIN$N PERIOD_M3 bar 2024.01.02 09:06: tick_volume=20077 real_volume=1      (iRealVolume=1)


The last bar before the test start (2023.12.28 18:24) is correct in all builds: tick_volume=1405, real_volume=10967.

Expected:

real_volume of M3 bars should match build 5833 and the chart-M3 run. For example, 100501 for the 09:03 bar.


Actual:

real_volume = 1 for every M3 bar formed during the test when the chart timeframe is not M3. The first bar of the day shows only a partial value (4434).


Impact:

Multi-timeframe strategies that use real volume produce different trades depending only on the chart timeframe selected in the tester. In our case, an EA produces 153 trades on an M3 chart and 0 trades on M1 or D1 charts over 2018–2024, with identical parameters.