Hi everyone,
I found these trading rules in a trading forum and I'm trying to translate them into Lite-C:

1. Set up your chart with any asset, 5 minute chart, starting at 9:30 AM Exchange time, and ending
at 3:15 PM.
2. Record the open of the first bar of the day, and refer to it as “openp”
3. At the close of the second bar of the day (at 9:40 AM) go long if:
A. The low of bar 2 is greater than openp
B. The 5 bar RSI indicator is below 50 OR both the close if greater than previous bar close AND
the close if greater than close 2 bars ago AND the daily close is less than the daily close 2 bars ago
4. At the close of the second bar of the day (at 9:40 AM) go short if:
A. The high of bar 2 is less than openp
B. The 5 bar RSI indicator is above 50 OR both the close if less than previous bar close AND the
close if less than close 2 bars ago AND the daily close is greater than the daily close 2 bars ago
5. If you are in a short trade, and the time is after than 11:00 AM and the position is profitable, exit at
the open of the next bar.

6. To add a volatility filter:
A. If the true range of the daily bar is greater than the average true range of the last 5 daily
bars, then:
1. No new trades can be entered
2. Any existing trades should be closed out
B. If the true range condition is not met, then trading should proceed as usual.

This is the Work-in-Progress Code:

Code
function run()
{
     
  
  StartDate = 2010; 
  EndDate = 2020;   
  BarPeriod = 5;	
  LookBack = 1000;	
  var Openp = priceOpen(2);
  var Close = priceClose();
  var Day0 =  dayClose(ET,0);
  var Day2 =  dayClose(ET,2);
  vars Closes = series(priceClose());
  asset("EUR/USD");
		
  
    if(timeOffset(ET,0,9,40) == 0) // enter a trade at second bar
  {    
    if(priceLow() > Openp
      && RSI(Closes,5) < 50
      || (priceClose() > priceClose(1) && priceClose() > priceClose(2) && Day0 < Day2))
      enterLong();
     
    if(priceHigh() < Openp
      && RSI(Closes,5) > 50
      || (priceClose() < priceClose(1) && priceClose() < priceClose(2) && Day0 > Day2))
      enterShort();
  }
}



I got this Error:

Error 045: Negative price offset at bar 11 and Zorro continues to train the algorithm indefinitely.
Nor do I understand how to execute numeral 6 "To add a volatility filter" in a trade that is already open.
I have tried to solve it and I have not been able, could you help me to solve it please?