CopyBuffer error

 

Hi, i want to call the most recent RSI value in the OnTick for multiple symbols although im currently getting the following error: 'CopyBuffer' - no one of the overloads can be applied to the function call. What's the solution?


string symbol_loop[] = {"USDJPY", "EURUSD", "USDCAD", "GBPUSD"};
int rsiHandle[];

datetime old_time;

//+-------------------------------------------------------------------------------------------------------+
//|  On OnInit                                                                                            |
//+-------------------------------------------------------------------------------------------------------+
int OnInit()
{
    
    for(int i = 0; i < ArraySize(symbol_loop); i++){
      rsiHandle[i] = iRSI(symbol_loop[i], PERIOD_CURRENT, 14, PRICE_CLOSE);
      
    }
    
    return(INIT_SUCCEEDED);
}

//+-------------------------------------------------------------------------------------------------------+
//|  On DeInit                                                                                            |
//+-------------------------------------------------------------------------------------------------------+
void OnDeinit(const int reason)
{
    // Deinitialize any resources if needed
}

//+-------------------------------------------------------------------------------------------------------+
//|  OnTick                                                                                               |
//+-------------------------------------------------------------------------------------------------------+
void OnTick()
{
   datetime GMT = iTime(_Symbol, PERIOD_M15, 1);
   if (GMT > old_time){
      old_time = GMT;

   for (int i = 0; i < ArraySize(symbol_loop); i++){
   string symbol = symbol_loop[i];
   
   double rsi[];
   ArraySetAsSeries(rsi, true);
   CopyBuffer(rsiHandle, MAIN_LINE, 1, 1, rsi);

   
   Print(rsi[0], " ", symbol);   
   }
   }
}
 
int OnInit()
{
    ArrayResize(rsiHandle, ArraySize(symbol_loop));
    for(int i = 0; i < ArraySize(symbol_loop); i++){
      rsiHandle[i] = iRSI(symbol_loop[i], PERIOD_CURRENT, 14, PRICE_CLOSE);
      
    }
    
    return(INIT_SUCCEEDED);
}

You have to allocate dynamic array before use like above.

CopyBuffer(rsiHandle[i], 0, 1, 1, rsi);

note: I did not even compile your code. There might be other issues.

Reason: