pine-script - 如何在前一根蜡烛的“收盘价”设置“止损”?
问题描述
我试图在过去的第二根蜡烛收盘时设置止损。我做的情节是准确的,但策略退出不是。有人可以帮我吗?
strategy("Test Strategy", overlay=true, pyramiding=0)
sma_short = sma(close, 21)
sma_medium = sma(close, 50)
sma_long = sma(close, 200)
is_up_trend = close[0] > close[1] and close > sma_short and sma_short > sma_medium and sma_medium > sma_long //and sma_short[0] > sma_short[1] and sma_medium[0] > sma_medium[1] and sma_long[0] > sma_long[1]
loss = close[0] - low[2]
plot(close[0] - loss, color=color.red, style=plot.style_stepline)
if crossover(sma_short, sma_medium) and is_up_trend
strategy.entry('long', strategy.long)
strategy.exit("long", loss=loss / syminfo.mintick)
解决方案
推荐阅读
- python - 如何根据顺序检测列表中的下一个任务
- mxgraph - 如何在 draw.io 中自动显示 mxGraphModel?
- asynchronous - 如何从 Tokio 的非主线程运行异步任务?
- javascript - Jest TypeError: Document.save 不是函数
- c - 在 C 中的数组中输入、查找和删除字符串
- c++ - 如何从找到的字符串中获取子字符串到 C++ 中的字符?
- reactjs - React JS 和 Redux:useSelector() 与 useStore()
- android - 蓝牙经典扫描不显示设备
- get - 到 Windows 10 事件/消息的 IP 电话操作 URL (HTTP GET)
- swift - iOS Swift - 在该模型中更改属性后读取持久数据模型