All of your script proposals contain many bugs, but right now I'm referring to your versions with the minute() rules:

- When using series(), always use them in the beginning of your run() function, NOT after an if-statement.
- day() refers to day of the month, see https://zorro-project.com/manual/en/month.htm. In your case you should use dow().
- isPositionOpen is declared as integer, but you're using it as a boolean in your if-statements.
- When printing something to the console, use a new line, so this means starting with '\n'.
- When closing a postion, simply use 'exitLong()'

Remark: there's no need to define the value 'isPositionOpen = 0' in the beginning, since '0' is already the default value.

Here's the fixed code:

Code
int isPositionOpen; // Variabile per tenere traccia dello stato della posizione

function run()
{	
set(PARAMETERS+LOGFILE);
BarPeriod = 1;

// Calcola l'RSI a 2 periodi
vars Price = series(price());
vars RSI2 = series(RSI(Price, 2));

if(dow() == 1 && hour() == 23 && minute() == 58)
{

if(RSI2[0] < 30 && isPositionOpen == 0)
{
enterLong(1);
isPositionOpen = 1; // Imposta lo stato della posizione su aperta
printf("\nEntered long position");
}
}

if(dow() == 3 && hour() == 0 && minute() == 5 && isPositionOpen == 1)
{
exitLong();
isPositionOpen = 0; // Imposta lo stato della posizione su chiusa
printf("\nExited long position");
}
}