0% found this document useful (0 votes)
187 views2 pages

indicator tradingview

Uploaded by

shyamgowtham606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views2 pages

indicator tradingview

Uploaded by

shyamgowtham606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

strategy("ICT Enhanced Breakout & Fibonacci Strategy", overlay=true)

// Input options
showSupportResistance = input(true, title="Show Support/Resistance Levels")
breakoutThreshold = input(1.5, title="Breakout Threshold (Multiplier)")
fibLookback = input(50, title="Lookback Period for Fibonacci Levels")
ratingStars = input(3, title="Rating for Strong Signal")
useICT = input(true, title="Use ICT Concepts (Order Blocks & Fair Value Gaps)")

// Calculate support and resistance using pivot points


support = ta.pivotlow(high, 10, 10)
resistance = ta.pivothigh(low, 10, 10)

// Check if support and resistance are valid


plotSupport = not na(support) ? support : na
plotResistance = not na(resistance) ? resistance : na

// Declare line variables


var line supportLine = na
var line resistanceLine = na

// Update support and resistance lines if enabled


if (showSupportResistance and not na(plotSupport))
supportLine := line.new(bar_index - 10, plotSupport, bar_index, plotSupport,
color=color.green, width=1, style=line.style_dotted)

if (showSupportResistance and not na(plotResistance))


resistanceLine := line.new(bar_index - 10, plotResistance, bar_index,
plotResistance, color=color.red, width=1, style=line.style_dotted)

// Calculate Fibonacci levels based on recent swing high and low


swingLow = ta.lowest(low, fibLookback)
swingHigh = ta.highest(high, fibLookback)

fibLevel236 = swingHigh - (swingHigh - swingLow) * 0.236


fibLevel382 = swingHigh - (swingHigh - swingLow) * 0.382
fibLevel50 = swingHigh - (swingHigh - swingLow) * 0.5
fibLevel618 = swingHigh - (swingHigh - swingLow) * 0.618
fibLevel786 = swingHigh - (swingHigh - swingLow) * 0.786

// Plot Fibonacci levels


plot(fibLevel236, color=color.blue, title="Fib 23.6%", linewidth=1)
plot(fibLevel382, color=color.blue, title="Fib 38.2%", linewidth=1)
plot(fibLevel50, color=color.blue, title="Fib 50.0%", linewidth=1)
plot(fibLevel618, color=color.blue, title="Fib 61.8%", linewidth=1)
plot(fibLevel786, color=color.blue, title="Fib 78.6%", linewidth=1)

// ICT Order Block Detection (Simple)


bullishOrderBlock = low[2] < low[1] and low[1] < low
bearishOrderBlock = high[2] > high[1] and high[1] > high

// ICT Fair Value Gap Detection


fvGapUp = close[2] < low[1] and high[1] < close
fvGapDown = close[2] > high[1] and low[1] > close

// Buy and Sell Signal Logic (Support/Resistance & Fibonacci Levels)


buySignalSR = ta.crossover(close, plotResistance * breakoutThreshold)
sellSignalSR = ta.crossunder(close, plotSupport * breakoutThreshold)
buySignalFib = ta.crossover(close, fibLevel382) or ta.crossover(close, fibLevel618)
sellSignalFib = ta.crossunder(close, fibLevel236) or ta.crossunder(close,
fibLevel50)

// Buy and Sell Signal Logic (ICT Concepts)


buySignalICT = (bullishOrderBlock and fvGapUp) or (buySignalFib and fvGapUp)
sellSignalICT = (bearishOrderBlock and fvGapDown) or (sellSignalFib and fvGapDown)

// Combine signals with ICT concepts


buySignal = (buySignalSR or buySignalICT) and close > fibLevel382
sellSignal = (sellSignalSR or sellSignalICT) and close < fibLevel50

// Plot Buy/Sell signals only when conditions are met


plotshape(buySignal, location=location.belowbar, color=color.green, text="BUY",
textcolor=color.white, size=size.large, title="Buy Signal")
plotshape(sellSignal, location=location.abovebar, color=color.red, text="SELL",
textcolor=color.white, size=size.large, title="Sell Signal")

// Execute trades based on signals


if (buySignal)
strategy.entry("Buy", strategy.long)

if (sellSignal)
strategy.entry("Sell", strategy.short)

// Close trades based on opposite signals


if (sellSignal)
strategy.close("Buy")

if (buySignal)
strategy.close("Sell")

// Display accuracy and debug information


var float totalSignals = 0
var float correctSignals = 0

if (buySignal or sellSignal)
totalSignals := totalSignals + 1
if (buySignal and close[1] < close)
correctSignals := correctSignals + 1
if (sellSignal and close[1] > close)
correctSignals := correctSignals + 1

accuracy = totalSignals > 0 ? (correctSignals / totalSignals) * 100 : 0


plot(accuracy, color=color.orange, title="Signal Accuracy (%)")

// Filter signals based on accuracy


minAccuracy = 90
if (accuracy < minAccuracy)
buySignal := false
sellSignal := false

You might also like