So after getting the prices from my CSV file, I am able to place the prices into the series. This series prints out the correct prices.

Code
vars readLatestPrices(string AssetName)
{
    string FilePath = strf("C:\\Users\\chu_h\\Desktop\\output\\%s.csv", AssetName);
    string content = file_content(FilePath);

    .....rest of the code
    
    vars ClosePrice= series(0, 1500);
    int i, idx;
    
    for(i = 0; i < size; i++) {
        idx = (head - 1 - i + 1500) % 1500;
        ClosePrice[i] = Prices[idx];
    }

    int i;
    for(i = 0; i < 10; i++) {
        printf("#Prices[%d] = %.6f\n", i, ClosePrice[i]); //Prints correct latest 10 prices
    }
    
    return CloseSeries;
}


However, when I try to use this prices series to create another series, Zorro doesn't seem to go though the series, and instead it remain at the latest price.

Code
vars Prices = readLatestPrices("GC_J");  //This gives the correct price series
vars PricesDiff = series(Prices[0] - Prices[1]);   //This always give same value, for example if ClosePrice[0]-ClosePrice[1] = 10, the series will just be 10,10,10,...
    
// Print the 10 most recent PricesDiff 
printf("\n#Asset: %s - Latest 10 PricesDiff (newest first):\n", "GC_J");
int i;
for(i = 0; i < 10; i++) {
    printf("#PricesDiff[%d] = %.6f\n", i, PricesDiff[i]);
}


The resulting PricesDiff series is such:
Code
#Asset: GC_J - Latest 10 PricesDiff (newest first):
PricesDiff[0] = 10
PricesDiff[1] = 10
PricesDiff[2] = 10
PricesDiff[3] = 10
PricesDiff[4] = 10
PricesDiff[5] = 10
PricesDiff[6] = 10
PricesDiff[7] = 10
PricesDiff[8] = 10
PricesDiff[9] = 10


It only prints out the difference of the first and second element (ClosePrice[0]-ClosePrice[1]), which is 10 in this case.

This is in contrast when Zorro get the price from T6, which Zorro will automatically loop through the previous series value to fill in the series.

Is there a way to make Zorro loop through CloseSeries to get correct PricesDiff, instead of having to rewrite the code with "for" loop to fill the series?

Last edited by vicknick; 03/16/25 14:59.