【问题标题】:how to refer to previous entry price in pinescript?如何在pinescript中参考之前的入场价格?
【发布时间】:2020-05-16 23:45:31
【问题描述】:

我想在 pine 中编写一个脚本,其中我的空头入场条件与我之前的多头入场价格相关,我该怎么做?例如当价格达到时做空(1.1*之前的做多价格) 到目前为止,我发现我可以通过 "close[]" 参考之前的蜡烛价格,但找不到参考之前的多头入场价格的方法。

在下面的示例中,我不知道该放什么来代替 ?作为之前多头条件价格的参考。

longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
    strategy.entry("buy", strategy.long)

shortCondition = close >= 1.1 * ?
if (shortCondition)
    strategy.exit("sell", strategy.short)

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    strategy.position_avg_price 为您提供多头和空头入场的平均价格

    strategy.long / strategy.short 为您提供多头或空头入场的价格

    【讨论】:

    • 是的,这正是我要找的...非常感谢,非常有帮助
    • strategy.long 是一个布尔值。它如何提供价格信息?
    • 我正在处理类似但不同的事情,仅在旧价格 stackoverflow.com/questions/67386653/…
    猜你喜欢
    • 1970-01-01
    • 2022-12-14
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-05
    • 2014-05-04
    • 2023-01-27
    相关资源
    最近更新 更多