//@version=3
study("5 Bars BreakOut",overlay=true)
Price = input(title="Price", defval=ohlc4 , type=source)
res=offset(highest(high,6),1)
sup=offset(lowest(low,6),1)
tsl=iff(valuewhen(iff(close>offset(res,1),1,iff(close<offset(sup,1),-1,0))!=0,iff(close>offset(res,1),1,iff(close<offset(sup,1),-1,0)),1)==1,sup,res)
Green = Price > tsl
Red = Price < tsl
BarColor = iff(Green,lime,red)
Buy = cross(Price,res)
Sell = cross(sup,Price)
barcolor(color=BarColor)
l1=plot(res,title='Resistant', color=lime)
//l2=plot(tsl,title='Trailling Stop Loss', color=navy)
l3=plot(sup,title='Support', color=red)
fill(l1,l3,BarColor)
by when green
sell when red
Good Luck
study("5 Bars BreakOut",overlay=true)
Price = input(title="Price", defval=ohlc4 , type=source)
res=offset(highest(high,6),1)
sup=offset(lowest(low,6),1)
tsl=iff(valuewhen(iff(close>offset(res,1),1,iff(close<offset(sup,1),-1,0))!=0,iff(close>offset(res,1),1,iff(close<offset(sup,1),-1,0)),1)==1,sup,res)
Green = Price > tsl
Red = Price < tsl
BarColor = iff(Green,lime,red)
Buy = cross(Price,res)
Sell = cross(sup,Price)
barcolor(color=BarColor)
l1=plot(res,title='Resistant', color=lime)
//l2=plot(tsl,title='Trailling Stop Loss', color=navy)
l3=plot(sup,title='Support', color=red)
fill(l1,l3,BarColor)
by when green
sell when red
Good Luck