I have a strategy that calculates whether to take a long/short and is then attempting to open a position and close that position. It doesn't seem to work so if anyone can spot anything.
float stopLoss = na
float takeProfit = na
if positionEntryShort and barstate.isconfirmed and strategy.position_size == 0
stopLoss := close - (syminfo.mintick * stopTicks)
takeProfit := close + (syminfo.mintick * profitTicks)
strategy.entry("Enter Short", strategy.short, qty = 1)
strategy.exit("Exit Short", from_entry="Enter Short", profit = takeProfit, stop = stopLoss, qty = 1)
if positionEntryLong and barstate.isconfirmed and strategy.position_size == 0
stopLoss := close - (syminfo.mintick * stopTicks)
takeProfit := close + (syminfo.mintick * profitTicks)
strategy.entry("Enter Long", strategy.long, qty = 1)
strategy.exit("Exit Long", from_entry="Enter Long", profit = takeProfit, stop = stopLoss, qty = 1)