OPEN-SOURCE SCRIPT

Breakout HANMANT

//version=5
indicator("Breakout", overlay=true)

// Define the condition for the previous candle
prevCandleOpen = ta.valuewhen(barstate.islast, open[1], 0)
prevCandleClose = ta.valuewhen(barstate.islast, close[1], 0)
prevCandleHigh = ta.valuewhen(barstate.islast, high[1], 0)
prevCandleLow = ta.valuewhen(barstate.islast, low[1], 0)

// Define the condition for the latest candle
latestCandleHigh = high
latestCandleLow = low

// Check for long condition
longCondition1 = (latestCandleHigh > math.max(prevCandleOpen, prevCandleClose, prevCandleHigh))
longCondition2 = (latestCandleLow > math.min(prevCandleOpen, prevCandleClose, prevCandleLow))
longCondition = longCondition1 and longCondition2

// Check for short condition
shortCondition1 = (latestCandleLow < math.min(prevCandleOpen, prevCandleClose, prevCandleLow))
shortCondition2 = (latestCandleHigh < math.max(prevCandleOpen, prevCandleClose, prevCandleHigh))
shortCondition = shortCondition1 and shortCondition2

// Plot the conditions
plotshape(longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")

//version=5
indicator("Inside Candle Strategy", overlay=true)

// Identify the previous candle's high and low
prevHigh = high[1]
prevLow = low[1]

// Identify the current candle's high and low
currHigh = high
currLow = low

// Check if the current candle is an inside candle
isInsideCandle = (currHigh < prevHigh) and (currLow > prevLow)

// Plotting the inside candle
bgcolor(isInsideCandle ? color.new(color.blue, 90) : na)

// Long and Short conditions
longCondition = isInsideCandle and (currHigh > currHigh[1])
shortCondition = isInsideCandle and (currLow < currLow[1])

// Generate signals
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")

// Alerts
Candlestick analysis

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal