OPEN-SOURCE SCRIPT
Мой скрипт

//version=4
study("BDBTW", overlay=true)
jawLength = input(13, minval=1, title="Jaw Length")
teethLength = input(8, minval=1, title="Teeth Length")
lipsLength = input(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
n = input(title="Periods Fractal", defval=2, minval=2, type=input.integer)
offsetFractal = input(100, title = "Offset Fractal")
offsetBDBTW = input(200, title = "Offset BDBTW")
upFractal = ( (high[n+2] < high[n]) and (high[n+1] < high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+3] < high[n]) and (high[n+2] < high[n]) and (high[n+1] == high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+4] < high[n]) and (high[n+3] < high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+5] < high[n]) and (high[n+4] < high[n]) and (high[n+3] == high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+6] < high[n]) and (high[n+5] < high[n]) and (high[n+4] == high[n]) and (high[n+3] <= high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
dnFractal = ( (low[n+2] > low[n]) and (low[n+1] > low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+3] > low[n]) and (low[n+2] > low[n]) and (low[n+1] == low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+4] > low[n]) and (low[n+3] > low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+5] > low[n]) and (low[n+4] > low[n]) and (low[n+3] == low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+6] > low[n]) and (low[n+5] > low[n]) and (low[n+4] == low[n]) and (low[n+3] >= low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
smma(src, len) =>
s = 0.0
s := na(s[1]) ? sma(src, len) : (s[1]*(len-1)+src)/len
r_hl=roc((high-low)/volume,1)
r_v=roc(volume,1)
sq_f=(r_hl < 0) and (r_v > 0)
jaw = smma(hl2, jawLength)
teeth = smma(hl2, teethLength)
lips = smma(hl2, lipsLength)
BDBup = high < jaw[jawOffset] and high < teeth[teethOffset] and high < lips[lipsOffset] and low < low[1] and close > hl2
BDBdown = low > jaw[jawOffset] and low > teeth[teethOffset] and low > lips[lipsOffset] and high > high[1] and close < hl2
plot(jaw, title = "Williams Alligator", offset = jawOffset, color=#3BB3E4)
plot(teeth, title = "Williams Alligator", offset = teethOffset, color=#FF006E)
plot(lips, title = "Williams Alligator", offset = lipsOffset, color=#36C711)
plotshape(dnFractal ? low[n] - offsetFractal * syminfo.mintick : na, title = "Fractals", style=shape.triangledown, location=location.belowbar, offset=-n, size = size.auto, color= color.maroon, transp=0)
plotshape(upFractal ? high[n] + offsetFractal * syminfo.mintick : na, title = "Fractals", style=shape.triangleup, location=location.abovebar, offset=-n, size = size.auto, color=color.olive, transp=0)
plotshape(BDBup ? high + offsetBDBTW * syminfo.mintick : na, title = "BDBTW buy", style=shape.circle, location=location.abovebar, color=color.green, size=size.auto, editable=true)
plotshape(BDBdown ? low - offsetBDBTW * syminfo.mintick : na, title = "BDBTW sell", style=shape.circle, location=location.belowbar, color=color.red, size=size.auto, editable=true)
ao = sma(hl2,5) - sma(hl2,34)
cao = change(ao)
barcolor(sq_f ? color.blue : cao <= 0 ? color.red : color.green, title = "Williams Squat Bars")
study("BDBTW", overlay=true)
jawLength = input(13, minval=1, title="Jaw Length")
teethLength = input(8, minval=1, title="Teeth Length")
lipsLength = input(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
n = input(title="Periods Fractal", defval=2, minval=2, type=input.integer)
offsetFractal = input(100, title = "Offset Fractal")
offsetBDBTW = input(200, title = "Offset BDBTW")
upFractal = ( (high[n+2] < high[n]) and (high[n+1] < high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+3] < high[n]) and (high[n+2] < high[n]) and (high[n+1] == high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+4] < high[n]) and (high[n+3] < high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ( (high[n+5] < high[n]) and (high[n+4] < high[n]) and (high[n+3] == high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+6] < high[n]) and (high[n+5] < high[n]) and (high[n+4] == high[n]) and (high[n+3] <= high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
dnFractal = ( (low[n+2] > low[n]) and (low[n+1] > low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+3] > low[n]) and (low[n+2] > low[n]) and (low[n+1] == low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+4] > low[n]) and (low[n+3] > low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ( (low[n+5] > low[n]) and (low[n+4] > low[n]) and (low[n+3] == low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+6] > low[n]) and (low[n+5] > low[n]) and (low[n+4] == low[n]) and (low[n+3] >= low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
smma(src, len) =>
s = 0.0
s := na(s[1]) ? sma(src, len) : (s[1]*(len-1)+src)/len
r_hl=roc((high-low)/volume,1)
r_v=roc(volume,1)
sq_f=(r_hl < 0) and (r_v > 0)
jaw = smma(hl2, jawLength)
teeth = smma(hl2, teethLength)
lips = smma(hl2, lipsLength)
BDBup = high < jaw[jawOffset] and high < teeth[teethOffset] and high < lips[lipsOffset] and low < low[1] and close > hl2
BDBdown = low > jaw[jawOffset] and low > teeth[teethOffset] and low > lips[lipsOffset] and high > high[1] and close < hl2
plot(jaw, title = "Williams Alligator", offset = jawOffset, color=#3BB3E4)
plot(teeth, title = "Williams Alligator", offset = teethOffset, color=#FF006E)
plot(lips, title = "Williams Alligator", offset = lipsOffset, color=#36C711)
plotshape(dnFractal ? low[n] - offsetFractal * syminfo.mintick : na, title = "Fractals", style=shape.triangledown, location=location.belowbar, offset=-n, size = size.auto, color= color.maroon, transp=0)
plotshape(upFractal ? high[n] + offsetFractal * syminfo.mintick : na, title = "Fractals", style=shape.triangleup, location=location.abovebar, offset=-n, size = size.auto, color=color.olive, transp=0)
plotshape(BDBup ? high + offsetBDBTW * syminfo.mintick : na, title = "BDBTW buy", style=shape.circle, location=location.abovebar, color=color.green, size=size.auto, editable=true)
plotshape(BDBdown ? low - offsetBDBTW * syminfo.mintick : na, title = "BDBTW sell", style=shape.circle, location=location.belowbar, color=color.red, size=size.auto, editable=true)
ao = sma(hl2,5) - sma(hl2,34)
cao = change(ao)
barcolor(sq_f ? color.blue : cao <= 0 ? color.red : color.green, title = "Williams Squat Bars")
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.