OPEN-SOURCE SCRIPT

Candle Color Confirmation Strategy

88
// TradingView (Pine Script v5) Strategy
//version=5
strategy("Candle Color Confirmation Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Input: Time confirmation in seconds
confirmTime = input(5, title="Seconds to Confirm")

// Track the candle open and its color consistency
var float openPrice = na
var bool isConfirmed = false
var bool isBullish = false
var int startTime = na

if bar_index != bar_index[1] // New candle
openPrice := open
isConfirmed := false
startTime := timenow

if not isConfirmed and (timenow - startTime) >= confirmTime * 1000
if close > openPrice and high == close // Green candle stays green
isBullish := true
strategy.entry("Buy", strategy.long)
isConfirmed := true
else if close < openPrice and low == close // Red candle stays red
isBullish := false
strategy.entry("Sell", strategy.short)
isConfirmed := true

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.