Exit on same bar OR

My Intraday strategy is to

Buy if low <= st // st = super trend

Sell = case1 or case2

case1: May be on the same bar if prices fall further and goes below st by 1% i.e L< st *0.99

(buy position remains open only if low doesn’t goes below st by 1%)

case2: if price closes below st “Cross(st, C)” but doesn’t fall 1% below the st

then record st-1 value of crossing candle, and exit if low < st-1 by 1%.

Sometimes price close below st but doesn’t fall by 1% and crosses back above the st

Cross(C, st); In that case I am resetting (sell crossing candle) to zero.

What I want my code to do

Buy = Ref(c, -1) >st and low <=st

buysig = Cross(C, st)

sellsig = Cross(st, C)

Exitlevel1 = (Ref(st, -1)*0.99)

Case1 = buyposition is open and sellsig = =0 and Low < Exitlevel1

Stoplevel = ValueWhen(Cross(st, C),Ref(st, -1))

Exitlevel2 = (Stoplevel*0.99)

Case2 = buyposition is open and sellsig == 1 and low < Exitlevel2

Sell = case1 or case2

Below is the code

SetOption("AllowSameBarExit", True );  
buysig = Cross(C, st);
sellsig = Cross(st, C);

Buy = ref(c, -1)>st and (L < =st);  

Exitlevel1 = (Ref(st, -1)*0.99);    
Exit1= low < exitlevel1;           
// Buy position is open and low is below st by 1%

Stoplevel = ValueWhen(Cross(st, C),Ref(st, -1));  
Exitlevel2 = (Stoplevel*0.99);
Exit2= low < exitlevel2;

sell = exit1 or exit2;

buysig =0;
sellsig =0;

for( i = 0; i < BarCount; i++ )
{
if( buysig [i] ) sellsig = 0; // reset sellsig on buy signal

{
if (sellsig[i] ) buysig = 0;  // reset buysig on sell signal
}

}

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

I am newbie. Please guide for this.