我正在尝试在交易日的最后 3 分钟生成卖出信号



我有一定的条件来生成买入和卖出信号,它们运行良好。但如果这是一天中的最后一个酒吧,无论我的其他条件如何,我都希望产生一个卖出信号,这样我就可以重新开始新的交易。这是我的代码,它为条件B或条件M生成一个卖出信号,但不为条件t1生成。我在想t1是一个布尔值,还是我错了?

t1 = time(timeframe.period, "1557-1600:23456")

// to buy conditions
if B==true  and M==true  // to buy conditions 
V5_Master_To_Buy := true
V5_Master_To_Sell := false
V5_Master_To_Sell
//to sell conditions 
else if B==false or M==false or t1==true
V5_Master_To_Sell := true
V5_Master_To_Buy := false
V5_Master_To_Buy

// Only show markers on transitions.
plotshape(V5_Master_To_Buy and not V5_Master_To_Buy[1], title="V5_Master_To_Buy", location=location.belowbar, color=color.lime, style=shape.triangleup, textcolor=color.yellow, text="BUY")            
plotshape(V5_Master_To_Sell and not V5_Master_To_Sell[1], title="V5_Master_To_Sell", location=location.abovebar, color=color.yellow, style=shape.triangledown, textcolor=color.yellow, text="SELL")

如有任何帮助,将不胜感激

事实上,您的t1变量总是会像这个一样返回true

BarInSession(sess) => not na(t1)
in_session = BarInSession("1557-1600")
if in_session
// generate sell signal

请记住,time((函数也允许使用第三个参数指定您想要的时区https://www.tradingview.com/pine-script-reference/v5/#fun_time

最新更新