Baekdoo Golden Diamond signal
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderbaekdoosan

//@version=5
indicator("Baekdoo golden diamond signal", overlay=true)

//cumulative volume
period=input(250)
VV=ta.highest(volume[1], period)
sumV=math.sum(volume[1], period)

//highest volume
count=ta.barssince(volume>=VV and close>open)
plot(count>0 and count <20 ? close*2:na, color=color.new(color.blue, 20), style=plot.style_areabr, display=display.none)

//higher than 10% of 1 year volume
ratio=input(0.1)
count2=ta.barssince(volume>=sumV*ratio and close>open)
plot(count2>0 and count2 <20 ? close : na, color=color.new(color.green, 20), style=plot.style_areabr, display=display.none)

//drops without volume
ratio2=input(0.5)
count3=ta.barssince((volume>=VV or volume>=sumV*ratio) and close>open)
plot(count3>0 and count3 <20 and volume<=ta.ema(volume[1], 5)*ratio2 and close<=ta.lowest(close[1], 5) ? close*1.5 : na, color=color.new(color.red, 20), style=plot.style_areabr, display=display.none)

//crossover 5 days resistance after dropping without volume
count4=ta.barssince(count3>0 and count3 <20 and volume<=ta.ema(volume[1], 5)*ratio2 and close<=ta.lowest(close[1], 5))
plotshape(count4>0 and count4 <10 and close>ta.highest(close[1], 5) ? close : na, color=color.new(color.yellow, 0), style=shape.diamond, display=display.all, size=size.normal)


