简体   繁体   中英

Plot buy or sell only when candle closes

I am developing a pine script indicator for Tradingview, and I would like some help: is there any code or command to make my plotshape command appear only after the candle closes? This would avoid premeditated signals, which can vary before the candle closes, and end up triggering alerts that can change over the candle's time. Thanks!

You can either use the historical operator with your condition and the shape will appear on the opening of the next new bar :

plotshape(my_condition[1])

or you can use barstate.isconfirmed along with your condition to have the shape rendered on it's own bar, but on the very last update of the bar

plotshape(my_condition and barstate.isconfirmed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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