my pine script strategy’s take profit is not being hit. I want to set Take Profit to High of previous candle. Currently, trades are being closed at End of Session.
E.g. i entered a buy at 10.45am, I want take profit to be set at 10.30am candle high Fixed. I’m using 15min timeframe only.
I’ve used high[1] and ta.highest[1] also.
var price1030high = 0.0
price1030high := (hour== 09 and minute == 30) ? high : price1030high
dailyclose2 = request.security(syminfo.tickerid, timeframe.period, high)
// Stops and Profit inputs
inpTakeProfit = price1030high
inpStopLoss = input.int(defval = 1000, title = "Stop Loss", minval = 0)
if (allLongLongs)
strategy.entry("Long", strategy.long, comment="LongEntry")
strategy.exit("Exit Long", from_entry = "Long", profit = inpTakeProfit, loss = inpStopLoss)
if not (allLongLongs) and (allLongLongs[25])
strategy.close_all("EOD")