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

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.