MetaTrader5: CopyBufferNormal and CopyRatesNormal as normal array

CopyBufferNormal and CopyRatesNormal – use these functions as normal array with classic index key!

int CopyBufferNormal(int indicator_handle, int buffer_num, int start_pos, int count, double &double_array[])
{
    int indicator_calculated = BarsCalculated(indicator_handle);
    if (count < 0) { start_pos += count + 1; count = 0 - count; }
    if (count == 0 || start_pos < 0 || start_pos + count > indicator_calculated) { return -1; }
    start_pos = indicator_calculated - count - start_pos;
    ArraySetAsSeries(double_array, false);
    int return_value = CopyBuffer(indicator_handle, buffer_num, start_pos, count, double_array);
    if (return_value <= 0) { ArrayResize(double_array, 0, 0); return -1; }
    return return_value;
}
int CopyRatesNormal(string symbol_name, ENUM_TIMEFRAMES timeframe, int start_pos, int count, MqlRates &rates_array[])
{
    int bars = Bars(symbol_name, timeframe);
    if (count < 0) { start_pos += count + 1; count = 0 - count; }
    if (count == 0 || start_pos < 0 || start_pos + count > bars) { return -1; }
    start_pos = bars - count - start_pos;
    ArraySetAsSeries(rates_array, false);
    int return_value = CopyRates(symbol_name, timeframe, start_pos, count, rates_array);
    if (return_value <= 0) { ArrayResize(rates_array, 0, 0); return -1; }
    return return_value;
}