问题描述
我正在研究涉及 Pine Script 的策略。我的策略涉及 20 周期的 RSI 指标。如果 RSI 穿过 70,我就买入,如果 RSI 穿过 30,我就卖出。但是,如果蜡烛穿过 70 或 30,我会在下一根蜡烛开盘时入场。开盘蜡烛必须低于 30 或 70,这就是我正在努力帮助的地方?
这是我的代码:
//@version=4
{ strategy("Bitcoin Strategy RSI",overlay = false,pyramiding = 0,currency = currency.USD,initial_capital = 10000,commission_value = 0)
period = input(20)
r = rsi(close,period)
plot(r,color = color.teal)
hline(30,color = color.white,linestyle = hline.style_dashed,linewidth = 1)
hline(70,linewidth = 1)
if (r < 30 and r[0] < 30)
strategy.entry( "Sell Entry",long = false)
if (r > 70 and r[0] > 70)
strategy.entry( "Buy Entry",long = true)
strategy.exit("Buy Exit","Buy Entry",profit = 150000,loss = 125000 )
strategy.exit("Selling Exit","Sell Entry",loss = 125000 )
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)