OPEN-SOURCE SCRIPT
BATOOT

//version=5
indicator('BATOOT', overlay=true)
length = input.int(title='Length', minval=1, maxval=1000, defval=18)
upBound = ta.highest(high, length)
downBound = ta.lowest(low, length)
LONG = ta.cross(high, upBound)
SHORT = ta.cross(low, downBound)
switch_1 = 0
setA = 0
setB = 0
if LONG and switch_1[1] == 0
switch_1 := 1
setA := 1
setB := 0
setB
else
if SHORT and switch_1[1] == 1
switch_1 := 0
setA := 0
setB := 1
setB
else
switch_1 := nz(switch_1[1], 0)
setA := 0
setB := 0
setB
plotshape(setA, title='LONG', style=shape.triangleup, text='BUY', color=color.new(color.green, 0), textcolor=color.new(color.green, 0), location=location.belowbar, size=size.small)
plotshape(setB, title='SHORT', style=shape.triangledown, text='SHORT', color=color.new(color.red, 0), textcolor=color.new(color.red, 0), location=location.abovebar, size=size.small)
alertcondition(setA, title='LONG', message='LONG!')
alertcondition(setB, title='SHORT', message='SHORT!')
//Support and Resistance
line_width = 3
sr_tf = input.timeframe('', title='S/R Timeframe')
//Legacy RSI calc
rsi_src = close
len = 9
up1 = ta.rma(math.max(ta.change(rsi_src), 0), len)
down1 = ta.rma(-math.min(ta.change(rsi_src), 0), len)
legacy_rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - 100 / (1 + up1 / down1)
//CMO based on HMA
length1 = 1
src1 = ta.hma(open, 5)[1] // legacy hma(5) calculation gives a resul with one candle shift, thus use hma()[1]
src2 = ta.hma(close, 12)
momm1 = ta.change(src1)
momm2 = ta.change(src2)
f1(m, n) =>
m >= n ? m : 0.0
f2(m, n) =>
m >= n ? 0.0 : -m
m1 = f1(momm1, momm2)
m2 = f2(momm1, momm2)
sm1 = math.sum(m1, length1)
sm2 = math.sum(m2, length1)
percent(nom, div) =>
100 * nom / div
cmo_new = percent(sm1 - sm2, sm1 + sm2)
//Legacy Close Pivots calcs.
len5 = 2
h = ta.highest(len5)
h1 = ta.dev(h, len5) ? na : h
hpivot = fixnan(h1)
l = ta.lowest(len5)
l1 = ta.dev(l, len5) ? na : l
lpivot = fixnan(l1)
//Calc Values
rsi_new = ta.rsi(close, 9)
lpivot_new = lpivot
hpivot_new = hpivot
sup = rsi_new < 25 and cmo_new > 50 and lpivot_new
res = rsi_new > 75 and cmo_new < -50 and hpivot_new
calcXup() =>
var xup = 0.0
xup := sup ? low : xup[1]
xup
calcXdown() =>
var xdown = 0.0
xdown := res ? high : xdown[1]
xdown
//Lines drawing variables
tf1 = request.security(syminfo.tickerid, sr_tf, calcXup(), lookahead=barmerge.lookahead_on)
tf2 = request.security(syminfo.tickerid, sr_tf, calcXdown(), lookahead=barmerge.lookahead_on)
//SR Line plotting
var tf1_line = line.new(0, 0, 0, 0)
var tf1_bi_start = 0
var tf1_bi_end = 0
tf1_bi_start := ta.change(tf1) ? bar_index : tf1_bi_start[1]
tf1_bi_end := ta.change(tf1) ? tf1_bi_start : bar_index
if ta.change(tf1)
tf1_line := line.new(tf1_bi_start, tf1, tf1_bi_end, tf1, color=color.green, width=line_width)
tf1_line
line.set_x2(tf1_line, tf1_bi_end)
var tf2_line = line.new(0, 0, 0, 0)
var tf2_bi_start = 0
var tf2_bi_end = 0
tf2_bi_start := ta.change(tf2) ? bar_index : tf2_bi_start[1]
tf2_bi_end := ta.change(tf2) ? tf2_bi_start : bar_index
if ta.change(tf2)
tf2_line := line.new(tf2_bi_start, tf2, tf2_bi_end, tf2, color=color.orange, width=line_width)
tf2_line
line.set_x2(tf2_line, tf2_bi_end)
indicator('BATOOT', overlay=true)
length = input.int(title='Length', minval=1, maxval=1000, defval=18)
upBound = ta.highest(high, length)
downBound = ta.lowest(low, length)
LONG = ta.cross(high, upBound)
SHORT = ta.cross(low, downBound)
switch_1 = 0
setA = 0
setB = 0
if LONG and switch_1[1] == 0
switch_1 := 1
setA := 1
setB := 0
setB
else
if SHORT and switch_1[1] == 1
switch_1 := 0
setA := 0
setB := 1
setB
else
switch_1 := nz(switch_1[1], 0)
setA := 0
setB := 0
setB
plotshape(setA, title='LONG', style=shape.triangleup, text='BUY', color=color.new(color.green, 0), textcolor=color.new(color.green, 0), location=location.belowbar, size=size.small)
plotshape(setB, title='SHORT', style=shape.triangledown, text='SHORT', color=color.new(color.red, 0), textcolor=color.new(color.red, 0), location=location.abovebar, size=size.small)
alertcondition(setA, title='LONG', message='LONG!')
alertcondition(setB, title='SHORT', message='SHORT!')
//Support and Resistance
line_width = 3
sr_tf = input.timeframe('', title='S/R Timeframe')
//Legacy RSI calc
rsi_src = close
len = 9
up1 = ta.rma(math.max(ta.change(rsi_src), 0), len)
down1 = ta.rma(-math.min(ta.change(rsi_src), 0), len)
legacy_rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - 100 / (1 + up1 / down1)
//CMO based on HMA
length1 = 1
src1 = ta.hma(open, 5)[1] // legacy hma(5) calculation gives a resul with one candle shift, thus use hma()[1]
src2 = ta.hma(close, 12)
momm1 = ta.change(src1)
momm2 = ta.change(src2)
f1(m, n) =>
m >= n ? m : 0.0
f2(m, n) =>
m >= n ? 0.0 : -m
m1 = f1(momm1, momm2)
m2 = f2(momm1, momm2)
sm1 = math.sum(m1, length1)
sm2 = math.sum(m2, length1)
percent(nom, div) =>
100 * nom / div
cmo_new = percent(sm1 - sm2, sm1 + sm2)
//Legacy Close Pivots calcs.
len5 = 2
h = ta.highest(len5)
h1 = ta.dev(h, len5) ? na : h
hpivot = fixnan(h1)
l = ta.lowest(len5)
l1 = ta.dev(l, len5) ? na : l
lpivot = fixnan(l1)
//Calc Values
rsi_new = ta.rsi(close, 9)
lpivot_new = lpivot
hpivot_new = hpivot
sup = rsi_new < 25 and cmo_new > 50 and lpivot_new
res = rsi_new > 75 and cmo_new < -50 and hpivot_new
calcXup() =>
var xup = 0.0
xup := sup ? low : xup[1]
xup
calcXdown() =>
var xdown = 0.0
xdown := res ? high : xdown[1]
xdown
//Lines drawing variables
tf1 = request.security(syminfo.tickerid, sr_tf, calcXup(), lookahead=barmerge.lookahead_on)
tf2 = request.security(syminfo.tickerid, sr_tf, calcXdown(), lookahead=barmerge.lookahead_on)
//SR Line plotting
var tf1_line = line.new(0, 0, 0, 0)
var tf1_bi_start = 0
var tf1_bi_end = 0
tf1_bi_start := ta.change(tf1) ? bar_index : tf1_bi_start[1]
tf1_bi_end := ta.change(tf1) ? tf1_bi_start : bar_index
if ta.change(tf1)
tf1_line := line.new(tf1_bi_start, tf1, tf1_bi_end, tf1, color=color.green, width=line_width)
tf1_line
line.set_x2(tf1_line, tf1_bi_end)
var tf2_line = line.new(0, 0, 0, 0)
var tf2_bi_start = 0
var tf2_bi_end = 0
tf2_bi_start := ta.change(tf2) ? bar_index : tf2_bi_start[1]
tf2_bi_end := ta.change(tf2) ? tf2_bi_start : bar_index
if ta.change(tf2)
tf2_line := line.new(tf2_bi_start, tf2, tf2_bi_end, tf2, color=color.orange, width=line_width)
tf2_line
line.set_x2(tf2_line, tf2_bi_end)
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.