【发布时间】:2022-11-20 20:29:46
【问题描述】:
我创建了一个指标,然后想用它来测试策略,但我的交易只有 2 或 3,而指标在图表中显示这么多,不确定我做错了什么?
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)
【问题讨论】:
标签: pine-script pinescript-v5 algorithmic-trading