Ahh I guess I understand now.
If I just print the prices as the come:

Code
function run(){
    BarPeriod = 1;
    LookBack = 240*100;
    StartDate = 20100101;
    EndDate = 20100201;

    asset("EURUSD");

    TimeFrame = 1;
    printf("\nM1: %.5f", priceClose());
    TimeFrame = 5;
    if (frame(0)) printf("\n --- M5: %.5f", priceClose());
}


The results are the expected: the last M1 candle closePrice() is the same that M5 candle closePrice(), as seen in the first attachment of this post. Now I understand that if the LookBack finishes not exactly in TimeFrame 5 frame(0) then the whole M1 series will be shifted, because it got new elements but the M5 series did not. Attachment.

One possible solution for printing is shifting the data inside the series:

Code
function run(){

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

    asset("EURUSD");

    TimeFrame = 1;
    vars priceM1 = series(priceClose(), 100);
    //printf("\nM1: %.5f", priceClose());
    TimeFrame = 5;
    vars priceM5 = series(priceClose(), 100);
    //if (frame(0)) printf("\n --- M5: %.5f", priceClose());

    if (!is(LOOKBACK)){

        //shift some data
        int i, j, shift;
        TimeFrame = 5;
        for (i=0; i<4; i++){
            if (frame(i)) shift = i + 1;
        }

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


Thank you!

Attached Files end_candle.pngshifting.png
Last edited by NorbertSz; 09/07/22 05:47.