For some reason, the profit-and-loss (P&L) doesn't calculate at buyclose; instead, it takes the P&L between buy and sell order. I want the trade to close when the buyclose criteria are met and calculate P&L.
buy = (close> s) and (close > s2)
buyclose = (close < s) or (close < s2)
if (buy)
strategy.entry("buy", long=true, when=buy)
strategy.close("buy",when=buyclose)