[英]How can I close the position with open_price of next bar in pine script
我的策略是在满足条件时。 我将以今天的收盘价买入,明天以开盘价卖出。 我想知道如何使用 strategy.close() 以下一根柱的开盘价平仓。
您可以将止损设置在一些极端水平,以便在下一个柱打开时立即触发退出。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius
//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.entry("Short", strategy.short)
if (strategy.position_size > 0)
strategy.exit("Long Exit", "Long", stop=10e16)
if (strategy.position_size < 0)
strategy.exit("Short Exit", "Short", stop=0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.