PROTECTED SOURCE SCRIPT
فلتر فوليوم

// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
//version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p[4]
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low[1] - area
, bar_index
, low[1] - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low[1] - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high[1] + area
, bar_index
, high[1] + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high[1] + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = ["MAs", "Oscillators", "All"])
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
[ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent] = request.security(syminfo.tickerid, res, rating.calcRatingAll())
[ratingTotal_mtf1, ratingOther_mtf1, ratingMA_mtf1] = request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
[ratingTotal_mtf2, ratingOther_mtf2, ratingMA_mtf2] = request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
[ratingTotal_mtf3, ratingOther_mtf3, ratingMA_mtf3] = request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
[ratingTotal_mtf4, ratingOther_mtf4, ratingMA_mtf4] = request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
[ratingTotal_mtf5, ratingOther_mtf5, ratingMA_mtf5] = request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong\nبوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong\nكول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int[] duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot[1]
count := math.min(5, count + 1)
else if v_plot < v_plot[1]
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong\nبوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong\nكول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
//version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p[4]
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low[1] - area
, bar_index
, low[1] - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low[1] - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high[1] + area
, bar_index
, high[1] + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high[1] + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = ["MAs", "Oscillators", "All"])
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
[ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent] = request.security(syminfo.tickerid, res, rating.calcRatingAll())
[ratingTotal_mtf1, ratingOther_mtf1, ratingMA_mtf1] = request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
[ratingTotal_mtf2, ratingOther_mtf2, ratingMA_mtf2] = request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
[ratingTotal_mtf3, ratingOther_mtf3, ratingMA_mtf3] = request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
[ratingTotal_mtf4, ratingOther_mtf4, ratingMA_mtf4] = request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
[ratingTotal_mtf5, ratingOther_mtf5, ratingMA_mtf5] = request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong\nبوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong\nكول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int[] duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot[1]
count := math.min(5, count + 1)
else if v_plot < v_plot[1]
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong\nبوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong\nكول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
//version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p[4]
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low[1] - area
, bar_index
, low[1] - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low[1] - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high[1] + area
, bar_index
, high[1] + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high[1] + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = ["MAs", "Oscillators", "All"])
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
[ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent] = request.security(syminfo.tickerid, res, rating.calcRatingAll())
[ratingTotal_mtf1, ratingOther_mtf1, ratingMA_mtf1] = request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
[ratingTotal_mtf2, ratingOther_mtf2, ratingMA_mtf2] = request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
[ratingTotal_mtf3, ratingOther_mtf3, ratingMA_mtf3] = request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
[ratingTotal_mtf4, ratingOther_mtf4, ratingMA_mtf4] = request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
[ratingTotal_mtf5, ratingOther_mtf5, ratingMA_mtf5] = request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong\nبوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong\nكول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int[] duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot[1]
count := math.min(5, count + 1)
else if v_plot < v_plot[1]
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong\nبوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong\nكول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
//version=6
indicator("فلتر فوليوم", max_labels_count = 500, max_lines_count = 500)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(20, minval=1, title="Filter Length")
bool disp_lvl = input.bool(true, "Levels")
color up_color = input.color(color.rgb(8, 245, 59), "", inline = "color")
color dn_color = input.color(color.rgb(243, 2, 2), "", inline = "color")
var buy_line = line(na)
var sell_line = line(na)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
float sma1 = ta.sma(close, 25)
float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25)
float area = ta.sma(high-low, 100)
// Two-pole smooth filter function
f_two_pole_filter(source, length) =>
var float smooth1 = na
var float smooth2 = na
alpha = 2.0 / (length + 1)
if na(smooth1)
smooth1 := source
else
smooth1 := (1 - alpha) * smooth1 + alpha * source
if na(smooth2)
smooth2 := smooth1
else
smooth2 := (1 - alpha) * smooth2 + alpha * smooth1
// Oscillator
two_p = f_two_pole_filter(sma_n1, length)
two_pp = two_p[4]
// Colors
color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na)
color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na)
color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color)
color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50))
color color = two_p > two_pp
? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0))
: color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color)
// Signals
bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed
bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed
// }
// PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
if buy //and two_p < -0.5
sell_line := line(na)
if disp_lvl
buy_line := line.new(
bar_index-1
, low[1] - area
, bar_index
, low[1] - area
, force_overlay = true
, color = buy_col1
, style = line.style_dashed
)
label.new(bar_index-1, low[1] - area
, color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny)
if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, buy_line.get_y1()
, color = color.new(up_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = up_color
)
buy_line := line(na)
if sell //and two_p > 0.5
buy_line := line(na)
if disp_lvl
sell_line := line.new(
bar_index-1
, high[1] + area
, bar_index
, high[1] + area
, force_overlay = true
, color = sell_col1
, style = line.style_dashed
)
label.new(bar_index-1, high[1] + area
, color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny)
if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed
label.new(
bar_index-1
, sell_line.get_y1()
, color = color.new(dn_color, 100)
, style = label.style_label_center
, force_overlay = true
, size = size.large
, text = "✖"
, textcolor = dn_color
)
sell_line := line(na)
switch
not na(buy_line) => buy_line. set_x2(bar_index)
not na(sell_line) => sell_line.set_x2(bar_index)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col2, -1, size = size.small)
plotshape(buy ? two_p[1] : na, "كول", shape.circle, location.absolute, buy_col1, -1, size = size.tiny)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col2, -1, size = size.small)
plotshape(sell ? two_p[1] : na, "بوت", shape.circle, location.absolute, sell_col1, -1, size = size.tiny)
p11 = plot(1, color = color.new(chart.fg_color, 80))
plot(0.5, color = color.new(chart.fg_color, 50))
p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0))
plot(-0.5, color = color.new(chart.fg_color, 50))
p_1 = plot(-1, color = color.new(chart.fg_color, 80))
fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na)
fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80))
p1 = plot(two_p, color = color, linewidth = 1)
p2 = plot(two_pp, display = display.none)
fill(p1, p2, two_p, two_pp, color, na)
// }
//version=6
// indicator("Technical Ratings", "Technicals", precision = 2)
import TradingView/TechnicalRating/3 as rating
res = input.timeframe("", "Indicator Timeframe")
ratingSignal = input.string("All", "Rating is based on", options = ["MAs", "Oscillators", "All"])
GRP1 = "Show MTF"
useMtf1 = input(false, "", inline = "mtf1", group = GRP1)
mtf1 = input.timeframe("60", "", inline = "mtf1", group = GRP1, active = useMtf1)
useMtf2 = input(false, "", inline = "mtf2", group = GRP1)
mtf2 = input.timeframe("240", "", inline = "mtf2", group = GRP1, active = useMtf2)
useMtf3 = input(true, "", inline = "mtf3", group = GRP1)
mtf3 = input.timeframe("1D", "", inline = "mtf3", group = GRP1, active = useMtf3)
useMtf4 = input(true, "", inline = "mtf4", group = GRP1)
mtf4 = input.timeframe("1W", "", inline = "mtf4", group = GRP1, active = useMtf4)
useMtf5 = input(true, "", inline = "mtf5", group = GRP1)
mtf5 = input.timeframe("1M", "", inline = "mtf5", group = GRP1, active = useMtf5)
GRP2 = "Color Settings"
colBuy = input(#5b9cf6, "Buy ", inline = "كول Colors", group = GRP2)
colStrongBuy = input(#2962ff, "", inline = "كول Colors", group = GRP2)
colNeutral = input(#a8adbc, "Neutral ", inline = "تذبذب", group = GRP2)
colSell = input(#ef9a9a, "Sell ", inline = "بوت Colors", group = GRP2)
colStrongSell = input(#f44336, "", inline = "بوت Colors", group = GRP2)
tableTitleColor = input(#295b79, "Headers", inline = "تذبذب", group = GRP2)
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
if ratingSignal == "MAs"
ratingMA
else if ratingSignal == "Oscillators"
ratingOther
else
ratingTotal
[ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent] = request.security(syminfo.tickerid, res, rating.calcRatingAll())
[ratingTotal_mtf1, ratingOther_mtf1, ratingMA_mtf1] = request.security(syminfo.tickerid, mtf1, rating.calcRatingAll())
[ratingTotal_mtf2, ratingOther_mtf2, ratingMA_mtf2] = request.security(syminfo.tickerid, mtf2, rating.calcRatingAll())
[ratingTotal_mtf3, ratingOther_mtf3, ratingMA_mtf3] = request.security(syminfo.tickerid, mtf3, rating.calcRatingAll())
[ratingTotal_mtf4, ratingOther_mtf4, ratingMA_mtf4] = request.security(syminfo.tickerid, mtf4, rating.calcRatingAll())
[ratingTotal_mtf5, ratingOther_mtf5, ratingMA_mtf5] = request.security(syminfo.tickerid, mtf5, rating.calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong\nبوت"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong\nكول "
else if value > WeakBound
"كول "
else
"تذبذب"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
int size = array.size(duplicatedIndex)-1
for j=0 to size
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int[] duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot[1]
count := math.min(5, count + 1)
else if v_plot < v_plot[1]
count := math.max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "بوت "
_returnColor := colSell
else if _signal == "Strong\nبوت"
_returnColor := colStrongSell
else if _signal == "كول "
_returnColor := colBuy
else if _signal == "Strong\nكول "
_returnColor := colStrongBuy
else if _signal == "تذبذب" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
f_drawInfo() =>
var t1 = table.new(position.middle_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
f_drawInfo()
plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
_cond1 = ta.crossunder(tradeSignal, -WeakBound)
alertcondition(_cond1, "بوت", "Ratings changed to بوت")
_cond2 = ta.crossover(tradeSignal, WeakBound)
alertcondition(_cond2, "كول", "Ratings changed to كول")
_cond3 = ta.crossunder(tradeSignal, -StrongBound)
alertcondition(_cond3, "Strong بوت", "Ratings changed to Strong بوت")
_cond4 = ta.crossover(tradeSignal, StrongBound)
alertcondition(_cond4, "Strong كول", "Ratings changed to Strong كول")
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.