Bobbin Detector
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © coinsspor

//@version=4
study("Bobbin Detector", overlay =true)

i = input(title="Bobbin Sensibility", type=input.float, defval=2.5, minval=0.1, maxval=10,step=0.1)
BW = input(title="Bobbin Box Width", type=input.integer, defval=140, minval=50, maxval=500,step=5)
bobin4a=close<close[1] and close[1]>close[2] and close[2]<close[3] and close[3]>close[4]
bobin4b=close>close[1] and close[1]<close[2] and close[2]>close[3] and close[3]<close[4]


Dizibobin4 = array.new_float()
array.unshift(Dizibobin4, abs(close-open)) 
array.unshift(Dizibobin4, abs(close[1]-open[1]))
array.unshift(Dizibobin4, abs(close[2]-open[2]))
array.unshift(Dizibobin4, abs(close[3]-open[3]))
buyuk4=array.max(Dizibobin4)
kucuk4=array.min(Dizibobin4)
oran4=buyuk4/kucuk4
kapanis4ENB=max(close,close[1],close[2],close[3])
acilis4ENK=min(open,open[1],open[2],open[3])

var box bobinkutu = na


if (( bobin4a or bobin4b )and oran4<=i)
    bobinkutu := box.new(left=bar_index-4, top=kapanis4ENB,right=bar_index + BW, border_color=color.red ,bottom=acilis4ENK,border_width=1, bgcolor=color.new(color.red, 80))






















