Professional Documents
Culture Documents
Trade Bulls v1.2
Trade Bulls v1.2
Trade Bulls v1.2
// Block Order
BO_on =input(defval=true, title='Enable Block Order', group='Block Order')
Senset = input.int(28, minval=1, title='Sensitivity', group='Block Order')
var int jj = na
if ta.crossover(CrDt, Senset)
BO_is_Upp := true
jj := bar_index
jj
if ta.crossunder(CrDt, -Senset)
BO_is := true
jj := bar_index
jj
// Sell/Buy/
BS_on =input(defval=true, title='Enable Buy/Sell', group='Buy/Sell')
LB_on =input(defval=true, title='Enable labels', group='Buy/Sell')
BS_type = input.string('Atr',options=['Atr','Manual'],inline='ln1',
group='Buy/Sell')
BS_size = input(1.,'',inline='ln1', group='Buy/Sell')
BS_max = input(3,'Sequence Length', group='Buy/Sell')
var BS_fib = array.from(1,1)
var BS_dist = 0.
var BS_avg = 0.
var BS_fib_n = 1
var BS_os = 0
BS_src = close
BS_n = bar_index
if barstate.isfirst
for i = 1 to BS_max
array.push(BS_fib,array.get(BS_fib,i-1) + array.get(BS_fib,i))
if BS_type == 'Atr'
BS_dist := ta.atr(200)*BS_size*array.get(BS_fib,BS_fib_n)
else
BS_dist := BS_size*array.get(BS_fib,BS_fib_n)
if BS_fib_n > BS_fib_n[1] and BS_os == 1 and BS_src > BS_avg and BS_on and LB_on
label.new(BS_n,BS_src,str.tostring(array.get(BS_fib,BS_fib_n-1)) + '
✅',yloc=yloc.abovebar,color=na,style=label.style_label_down,textcolor=color.gray,si
ze=size.small)
else if BS_fib_n > BS_fib_n[1] and BS_os == 1 and BS_src < BS_avg and BS_on and
LB_on
label.new(BS_n,BS_src,str.tostring(array.get(BS_fib,BS_fib_n-1)) + '
❌',yloc=yloc.belowbar,color=na,style=label.style_label_up,textcolor=color.gray,size
=size.small)
if BS_fib_n > BS_fib_n[1] and BS_os == 0 and BS_src < BS_avg and BS_on and LB_on
label.new(BS_n,BS_src,str.tostring(array.get(BS_fib,BS_fib_n-1)) + '
✅',yloc=yloc.belowbar,color=na,style=label.style_label_up,textcolor=color.gray,size
=size.small)
else if BS_fib_n > BS_fib_n[1] and BS_os == 0 and BS_src > BS_avg and BS_on and
LB_on
label.new(BS_n,BS_src,str.tostring(array.get(BS_fib,BS_fib_n-1)) + '
❌',yloc=yloc.abovebar,color=na,style=label.style_label_down,textcolor=color.gray,si
ze=size.small)
//Channel
CH_on =input(defval=true, title='Enable Channel', group='Channel')
CH_src = input(defval=close, title='Source', group='Channel')
CH_len = input.int(defval=100, title='Length', minval=10, group='Channel')
CH_divlen = input.float(defval=2., title='Deviation', minval=0.1, step=0.1,
group='Channel')
CH_ext = input(defval=true, title='Extend Lines', group='Channel')
CH_shwfib = input(defval=false, title='Show Fibonacci Levels', group='Channel')
CH_shwbrk = input.bool(defval=true, title='Show Broken Channel', inline='brk',
group='Channel')
CH_brkclr = input.color(defval=color.blue, title='', inline='brk', group='Channel')
CH_upclr = input.color(defval=color.lime, title='Up/Down Trend Colors',
inline='trcols', group='Channel')
CH_dnclr = input.color(defval=color.red, title='', inline='trcols',
group='Channel')
CH_lnwdt = input(defval=2, title='Line Width', group='Channel')
var CH_fiboln = array.new_float(0)
var CH_clrs = array.new_color(2)
if barstate.isfirst
array.push(CH_fiboln, 0.236)
array.push(CH_fiboln, 0.382)
array.push(CH_fiboln, 0.618)
array.push(CH_fiboln, 0.786)
array.unshift(CH_clrs, CH_upclr)
array.unshift(CH_clrs, CH_dnclr)
get_Channel(CH_src, CH_len) =>
md = math.sum(CH_src, CH_len) / CH_len
Ugl = ta.linreg(CH_src, CH_len, 0) - ta.linreg(CH_src, CH_len, 1)
ip = md - Ugl * math.floor(CH_len / 2) + (1 - CH_len % 2) / 2 * Ugl
lst = ip + Ugl * (CH_len - 1)
dev = 0.0
for x = 0 to CH_len - 1 by 1
dev += math.pow(CH_src[x] - (Ugl * (CH_len - x) + ip), 2)
dev
dev := math.sqrt(dev / CH_len)
[ip, lst, dev, Ugl]
[y1_, y2_, dev, Ugl] = get_Channel(CH_src, CH_len)
CH_break = Ugl > 0 and close < y2_ - dev * CH_divlen ? 0 : Ugl < 0 and close > y2_
+ dev * CH_divlen ? 2 : -1
var CH_rlns = array.new_line(3)
var CH_fiblns = array.new_line(4)
if CH_on
for x = 0 to 2 by 1
if not CH_shwbrk or CH_break != x or nz(CH_break[1], -1) != -1
line.delete(array.get(CH_rlns, x))
else
line.set_color(array.get(CH_rlns, x), color=CH_brkclr)
line.set_width(array.get(CH_rlns, x), width=2)
line.set_style(array.get(CH_rlns, x), style=line.style_dotted)
line.set_extend(array.get(CH_rlns, x), extend=extend.none)
array.set(CH_rlns, x, line.new(x1=bar_index - (CH_len - 1), y1=y1_ +
dev * CH_divlen * (x - 1), x2=bar_index, y2=y2_ + dev * CH_divlen * (x - 1),
color=array.get(CH_clrs, math.round(math.max(math.sign(Ugl), 0))), style=x % 2 == 1
? line.style_solid : line.style_dashed, width=CH_lnwdt, extend=CH_ext ?
extend.right : extend.none))
if CH_shwfib
for x = 0 to 3 by 1
line.delete(array.get(CH_fiblns, x))
array.set(CH_fiblns, x, line.new(x1=bar_index - (CH_len - 1), y1=y1_ - dev
* CH_divlen + dev * CH_divlen * 2 * array.get(CH_fiboln, x), x2=bar_index, y2=y2_ -
dev * CH_divlen + dev * CH_divlen * 2 * array.get(CH_fiboln, x),
color=array.get(CH_clrs, math.round(math.max(math.sign(Ugl), 0))),
style=line.style_dotted, width=CH_lnwdt, extend=CH_ext ? extend.right :
extend.none))
var label lbl1 = label.new(x=bar_index - (CH_len - 1), y=y1_, text='S',
size=size.large)
lb_text = Ugl > 0 ? Ugl > Ugl[1] ? '⇑' : '⇗' : Ugl < 0 ? Ugl < Ugl[1] ? '⇓' : '⇘' :
'⇒'
lb_style = Ugl > 0 ? Ugl > Ugl[1] ? label.style_label_up :
label.style_label_upper_right : Ugl < 0 ? Ugl < Ugl[1] ? label.style_label_down :
label.style_label_lower_right : label.style_label_right
if CH_on
label.set_style(lbl1, lb_style)
label.set_text(lbl1, lb_text)
label.set_x(lbl1, bar_index - (CH_len - 1))
label.set_y(lbl1, Ugl > 0 ? y1_ - dev * CH_divlen : Ugl < 0 ? y1_ + dev *
CH_divlen : y1_)
label.set_color(lbl1, Ugl > 0 ? CH_upclr : Ugl < 0 ? CH_dnclr : color.blue)
// Support/Resistance
SR_on =input(defval=true, title='Enable Support/Resistance',
group='Support/Resistance')
SR_lb = input(15, title='Left Bars ', group='Support/Resistance')
SR_rb = input(15, title='Right Bars', group='Support/Resistance')
SR_vol = input(20, title='Volume Threshold', group='Support/Resistance')
SR_high = fixnan(ta.pivothigh(SR_lb, SR_rb)[1])
SR_low = fixnan(ta.pivotlow(SR_lb, SR_rb)[1])
plot(SR_on?SR_low:na, color=ta.change(SR_low) ? na : #2030e0, linewidth=3, offset=-
(SR_rb + 1), title='Support')
plot(SR_on?SR_high:na, color=ta.change(SR_high) ? na : #F00000, linewidth=3,
offset=-(SR_rb + 1), title='Resistance')
SR_short = ta.ema(volume, 5)
SR_long = ta.ema(volume, 10)
SR_dlt = 100 * (SR_short - SR_long) / SR_long
alertcondition(ta.crossover(close, SR_high) and SR_dlt > SR_vol, title='Resistance
Broken', message='Resistance Broken')
alertcondition(ta.crossunder(close, SR_low) and SR_dlt > SR_vol, title='Support
Broken', message='Support Broken')