【发布时间】:2020-06-06 11:29:19
【问题描述】:
我尝试在 Pine 编辑器中编写策略脚本。
- strategy.entry() 工作正常。
- 但是按照我的逻辑,strategy.exit() 不工作。
- 我的退出计算是前一根蜡烛的高点减去低点。
我是 Pine 的新手。下面是我的代码。有人可以指出什么是错的吗?
Short = ( ( close[1] > open[1] ) and ( high < high[1] ) and ( close < low[1] ) )
if ( Short )
Target = high[1] - low[1]
Loss = high[1] - low[1]
strategy.entry("Enter Short", strategy.short, 1, when = window() )
strategy.exit("Enter Short", "Enter Short", stop=Loss, limit=Target, when = window())
【问题讨论】:
-
你确定你有一个正确的格式,即 if 语句内的块有 4 个空格吗?
-
嗨,帕洛,是的。我在想变量(目标,损失)值没有传递到 strategy.exit() 中。我是否缺少将价格值传递给 strategy.exit() 以进行止损和限价的东西?
-
您好 Palo,使用以下代码实现 =========================== ==================== '目标 = valuewhen(( ( close[1] > open[1] ) and ( high
-
你可以把它写成答案,然后接受它。
标签: pine-script