Hey I'm trying to save the close price at the time of strategy.entry to a variable so I can use it later for an exit.
if condition
strategy.entry("long", true)
buyprice=close
(strategy.exit("exit","long", when = close>buyprice*1.1)
I get the error: Undeclared identifier 'buyprice'
. From what I understand this means that the variable is not valid outside of the if statement. Is there a way to change this? Thanks in advance for your help