【发布时间】:2020-12-08 10:01:54
【问题描述】:
我了解当价格高于当前市场价格时会出现买入止损。
我需要了解为何此处会出现买入止损单。我不太明白 RSI 信号指标如何影响买入止损?
这是代码
//if above 70 , overbought , if below 30, then oversold
strategy(title="Stop Order RSI Strategy", shorttitle="Stop Order RSI", format=format.price, precision=2)
//Inputs
i_oversold = input(30 , title="Oversold")
i_overbought = input(70 , title="Overbought")
len = input(14, minval=1, title="Length")
src = input(close, "Source", type = input.source)
//Calculations
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//Plotting
plot(rsi, "RSI", color=#8E1599)
band1 = hline(70, "Upper Band", color=#C0C0C0)
band0 = hline(30, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=#9915FF, transp=90, title="Background")
goLong = rsi < i_oversold
goShort = rsi > i_overbought
strategy.entry("Buy Stop" , stop=high , when = goLong , long = true)
strategy.entry("Sell Stop" , stop=low , when = goShort , long = strategy.short)
感谢有人能花时间解释这里发生了什么,因为我很迷茫。
【问题讨论】:
-
我已将那段代码放入策略中。它不会在该柱上产生信号。请编辑您的问题并发布整个脚本。
-
@BjornMistiaen 我已经更新并粘贴了整个脚本。非常感谢您对此进行调查。
标签: pine-script algorithmic-trading trading