I've been trying to make a new simple strategy based on Stoch RSI and it was successful with this simple code
strategy("Long Strategy", overlay=true)
length = input.int(10, minval=1)
OverBought = input(85)
OverSold = input(5)
smoothK = 3
smoothD = 3
k = ta.sma(ta.stoch(close, high, low, length), smoothK)
d = ta.sma(k, smoothD)
b = ta.crossover(k,OverSold)
s = ta.crossunder(d,OverBought)
strategy.entry("Buy", strategy.long, when=(b and k > OverSold), comment="Buy")
strategy.close("Buy", when=(s and d < OverBought), comment="Sell")
But I wanted to edit it so that the strategy.close would be fulfilled only when above entry price. So, I edited the code, and I've been trying to find what's wrong with line 17 but I can't seem to.
The error says "line 17: Syntax error at input 'strategy.long'."
The code after editing is as follows:
strategy("Stoch. RSI", format=format.price, overlay=true)
length = input.int(10, minval=1)
OverBought = input(85)
OverSold = input(5)
smoothK = 3
smoothD = 3
k = ta.sma(ta.stoch(close, high, low, length), smoothK)
d = ta.sma(k, smoothD)
b = ta.crossover(k,OverSold)
s = ta.crossunder(d,OverBought)
var price = 0.0
if (b and k > OverSold) and strategy.position_size == 0
price := close`
strategy.entry(id="buy", strategy.long , comment="Buy")
if (s and d < OverBought) and (price > close)
strategy.close(id="buy", comment="Sell")