早上好,
我如何配置tradingview,以便在进入相反操作之前,它用 tp/sl 关闭操作。例如,我持有多头,但它只给出空头信号,我该如何设置,以便在开空头之前先平掉多头,然后在开空头之后立即平仓?非常感谢你。
在新入场之前有退出信号
您只需在
strategy.close()
之前致电 strategy.entry()
。
//@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.close("Short")
strategy.entry("Long", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.close("Long")
strategy.entry("Short", strategy.short)