get value from RSIonarray - wrong output

 

hi

my code for getting information from RSIonarray is :

//+------------------------------------------------------------------+
//|                                                            t.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property script_show_inputs
#include <RSIOnArray.mqh>
input int bar;
input int period;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
  double closes[];
  for(int i=0;i<=bar;i++)
  {
  ArrayResize(closes,i+1);
  closes[i]=close(i+1);
  }
  ArrayReverse(closes);
   Print(DoubleToString(iRSIOnArray(closes,0,period,0),2));
  }
//+------------------------------------------------------------------+
double close(int num){return iClose(_Symbol,0,num);}

can you tell me why  outpuut is changed when i change the ((bar)) in input?