Home>

I'm in trouble because I can't understand the array at all.

How can I arrange the current candlestick, the candlestick one day ago, and the candlestick two days ago?
I'm trying it like this myself, but I don't understand the array well and it doesn't work very well.

int i;
double H [i] = [iHigh (NULL, PERIOD_D1, i)];
double L [i] = [iLow (NULL, PERIOD_D1, i)];
double O [i] = [iOpen (NULL, PERIOD_D1, i)];
double C [i] = [iClose (NULL, PERIOD_D1, i)];

  • Answer # 1

    Is it like this?

    When writing solid

      double H [3];
        double L [3];
        double O [3];
        double C [3];
        H [0] = iHigh (NULL, PERIOD_D1, 0);// Currently
        H [1] = iHigh (NULL, PERIOD_D1, 1);// 1 day ago
        H [2] = iHigh (NULL, PERIOD_D1, 2);// 2 days ago
        L [0] = iLow (NULL, PERIOD_D1, 0);// Currently
        L [1] = iLow (NULL, PERIOD_D1, 1);// 1 day ago
        L [2] = iLow (NULL, PERIOD_D1, 2);// 2 days ago
        ...

    When initializing with a loop

      double H [3];
        double L [3];
        double O [3];
        double C [3];
        for (int i = 0;i<3;i ++)
        {
            H [i] = iHigh (NULL, PERIOD_D1, i);
            L [i] = iLow (NULL, PERIOD_D1, i);
            O [i] = iOpen (NULL, PERIOD_D1, i);
            C [i] = iClose (NULL, PERIOD_D1, i);
        }