简体   繁体   English

如何在 pinescript 中参考之前的入场价格?

[英]how to refer to previous entry price in pinescript?

I want to write an script in pine in which my short entry condition is related to my previous long entry price, how can I do it?我想在pine中编写一个脚本,其中我的空头入场条件与我之前的多头入场价格相关,我该怎么做? for example short entry when price hits (1.1*previous long entry price) so far I found out I can refer to previous candles price by "close[]" but couldn't find a way to refer to previous long entry price.例如,当价格触及(1.1*之前的多头入场价格)时空头入场,到目前为止我发现我可以通过“close[]”参考之前的蜡烛价格,但找不到参考之前多头入场价格的方法。

In the example below I don't know what to put instead of?在下面的示例中,我不知道该用什么代替? as a reference to previous long condition price.作为先前多头条件价格的参考。

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)

strategy.position_avg_price gives you the average price for long and short entries strategy.position_avg_price 为您提供多头和空头条目的平均价格

strategy.long / strategy.short gives you the price for long or short entries strategy.long / strategy.short 为您提供多头或空头条目的价格

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM