Basically what I want to do is if the open is above the BuyLine (signal=1) to buy a hit of that line with stop at the SellLine and vice versa, if the open is below the SellLine (signal=-1) to sell a hit of the SellLine with stop at the BuyLine.
The problem is that the backtest gives trades at wrong places. Can you help me spot the problem in the code please?