Buy and Sell from the Lowest Highest since Buy or Sell

I have problems to set this in the right field or might be the function is wrong which I am using. Can someone help me to get better here or any examples.
Thanks. !

// Description
//System goes long if the Lowest Low  at the beginning period is 4 % higher 
//exit if the Highest High since Buy is 4 % lower than close
//Go long again if the Low since Exit is 4 % higher than close again 

 
 

ThisBarExitPrice =  H *  0.96;
ThisBarEntryPrice = L *  1.04;

Buy = Close > LowestSince(Sell,ThisBarExitPrice,1); 
Sell = Close < HighestSince(Buy,ThisBarExitPrice,1);

BuyPrice = C;
SellPrice = C;
 
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
 
Filter =1;

AddTextColumn( FullName(), "Company Name" );
AddColumn( IIf(Buy, 1, Null), "Buy", 1 );
AddColumn( IIf(Sell, 1, Null), "Sell", 1 );
AddColumn( C, "Close", 1.2 );
AddColumn( ThisBarEntryPrice, "entry level", 1.2 );
AddColumn( ThisBarExitPrice, "exit Price", 1.2 );
AddColumn( Lowest(L), "LowestL", 1.2 );
AddColumn( Highest(H), "HighestH", 1.2 );
 

// Charting //
Plot( ThisBarEntryPrice, "stop line for Entry", colorRed, styleThick );
Plot( ThisBarExitPrice, "stop line for Exit", colorRed, styleThick );

Bild

1 Like

This part is still not clear.

Beginning period of what?

4 % lower than close, which close?

Not sure if you got your answer but

Buy = Close > LowestSince(Sell,ThisBarExitPrice,1);

references Sell before it has been initialised