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. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.