Dear all,

Could you help me understand what am I missing?

Code
function run(){

    BarPeriod = 1;
    LookBack = 240*100;
    StartDate = 20100101;
    EndDate = 20100201;

    set(NOSHIFT);           //shift manually
    asset("EURUSD");
    
    vars priceM1 = series();
    vars priceM5 = series();

    if (is(INITRUN)){
        priceM1 = series(0, 100);
        priceM5 = series(0, 100);
    }
    
    TimeFrame = 1;
    shift(priceM1, priceClose(), 100);
    TimeFrame = 5;
    if (frame(0)) shift(priceM5, priceClose(), 100);

    if (!is(LOOKBACK)){
        int i, j;
        for (i=0; i<10; i++){
            printf("\n--- M5: %.5f", priceM5[i]);
            for (j=0; j<5; j++){
                printf("\n M1: %.5f", priceM1[i*5+j]);
            }
        }
        quit(0);
    }
}


I attached the results.
How is it possible that the M1 middle candle is determining the closing price of the M5 candle? Shouldn't it be the last one?
The expected result are the following:

Code
--- M5 priceE
M1 priceA
M1 priceB
M1 priceC
M1 priceD
M1 priceE
...


Thank you!

Attached Files middle_candle.png