I created an indicator and then want to use it to test in strategy but my trades are only 2 or 3 while the indicator shows so many in the chart, not sure what am i doing wrong?
strategy('AMI short', overlay = true)
ema5 = ta.ema(close,100)
rsi = ta.rsi(close, 14)
plot(ema100, linewidth = 2, color = color.yellow)
currentcrossbelow = close < low[1]
previousdetachedabove = low[1] > ema100[1]
shortSignal = currentcrossbelow and previousdetachedabove and high < high[1]
bgcolor(shortSignal ? color.new(color.red, 40) : na)
SL = 0.05
TP = 0.10
shortStop = strategy.position_avg_price*(1+SL)
shortProfit = strategy.position_avg_price*(1-TP)
if shortSignal
strategy.entry('Short', strategy.short, 1)
if strategy.position_avg_price > 0
strategy.exit('closeShort', stop = shortStop, limit = shortProfit)