I am new to trading view and have very little programming background. I am trying to write a simple strategy to buy when RSI hits 30 and sell when the price rises by 5% after my entry.
I am not sure how to go about exiting the trade. See code below, can you help me out please?
```fromYear = year >= 2010
toYear = year <= 2020
longCondition = rsi(close, 21) < 30
if (longCondition and fromYear and toYear)
strategy.entry(Long 1
, strategy.long)
entry_price = valuewhen(longCondition, open, 0)
exit_price = entry_price * 1.05
closeCondition = exit_price
if (closeCondition)
strategy.close(Long 1
)```