indicator
indicator
// Input parameters
prd = input(defval = 10, title="Loopback Period", minval = 2, maxval = 50)
conslen = input(defval = 5, title="Min Consolidation Length", minval = 2,
maxval = 20)
paintcons = input(defval = true, title = "Paint Consolidation Area ")
zonecol = input(defval = color.new(color.blue, 70), title = "Zone Color")
for x = 0 to 1000
if na(close) or dir != dir[x]
break
if zz[x]
if na(pp)
pp := zz[x]
else
if dir[x] == 1 and zz[x] > pp
pp := zz[x]
if dir[x] == -1 and zz[x] < pp
pp := zz[x]
if change(pp)
if conscnt > conslen
if pp > condhigh
breakoutup := true
if pp < condlow
breakoutdown := true
if conscnt > 0 and pp <= condhigh and pp >= condlow
conscnt := conscnt + 1
else
conscnt := 0
else
conscnt := conscnt + 1
// Plot EMAs
plot(ema5, color=color.blue, title="EMA 5")
plot(ema9, color=color.red, title="EMA 9")
if buySignal
entryPrice := close
stopLoss := low
target1 := entryPrice + (entryPrice - stopLoss) * 2
target2 := entryPrice + (entryPrice - stopLoss) * 3
target3 := entryPrice + (entryPrice - stopLoss) * 5
if sellSignal
entryPrice := close
stopLoss := high
target1 := entryPrice - (stopLoss - entryPrice) * 2
target2 := entryPrice - (stopLoss - entryPrice) * 3
target3 := entryPrice - (stopLoss - entryPrice) * 5