Add alert conditions pause and resume method on pinescript

Job ID: 35564640

Budget: $10 – $11 USD

I just want frw lines of code to be fixed and working, the concept is simple.

condition = close > 1.50
var resume = true
var TP = 0
var SL = 0

1. if my condition is true then set the sl and tp in a label.new with their values which is +0.5% of close price as Take profit and -0.5% of close price as Stoploss.
TP := close + (close * 0.005)
SL := close - (close * 0.005)

2. my alert condition (condition and resume == true, message='Buy') is triggered, note the alert condition is set to run every minute or bar close as frequency.

3. then once the first alert condition is triggered resume := false
this means the alert condition will be paused from firing again until resume becomes true.

4. to turn the resume back
if close > TP or close < SL
resume = true

This is simply what i intend to add to the script, for some reasons is not working for me, because the variables does not respond to the if statements or they are assuming the last value, as resume is constantly turned false or permanently turned true which makes my triggers to keep running even when i have a buy order in like an open order.
Related categories: Pine Script Trading