Help Me
Help Me
// Signals
nbuysell = input.bool(true, 'Show Signals', inline = "BSNM",group='BUY AND SELL
SIGNALS SETTINGS')
nsensitivity = input.float(defval=2, title="Sensitivity", minval=1, maxval=20,
group='BUY AND SELL SIGNALS SETTINGS')
smartsignalsonly = input.bool(false, 'Smart Signals Only',group='BUY AND SELL
SIGNALS SETTINGS')
barcoloringmode = input.string("Trend", "Bar Coloring", ["Gradient", "Trend"],
inline="levels", group = 'BUY AND SELL SIGNALS SETTINGS')
//candlecolor = input.bool(true, 'Buy/Sell Signal', inline =
"BSNM",group='BUY/SELL SIGNAL')
ema200con = ta.ema(close,200)
// Risk Management
// Input settings
history_of_demand_to_keep = 20
show_zigzag = false
show_price_action_labels = false
swing_length = 8
box_width = 4
box_extend_option = "Both"
res = ''
s1 = request.security(syminfo.tickerid, res, showsr, gaps=barmerge.gaps_on)
demand_color = #0395ff4d
supply_color = #ff00024d
// Signal Generation
supertrend(_close, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _close + factor * atr
lowerBand = _close - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
direction := 1
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
[superTrend, direction]
// SMA
ocAvg = math.avg(open, close)
sma4 = ta.sma(close, 50)
sma5 = ta.sma(close, 200)
sma9 = ta.sma(close, 13)
psar = ta.sar(0.02, 0.02, 0.2)
//*in Easy Words Super Trend + SMA = Signals
[supertrend, direction] = supertrend(close, nsensitivity*2, 11)
// Colors
green = #0395ff, green2 = #0395ff
red = #ff0002, red2 = #ff0002
adxlen = 15
dilen = 15
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : up > down and up > 0 ? up : 0
minusDM = na(down) ? na : down > up and down > 0 ? down : 0
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adx
sig = adx(dilen, adxlen)
// High Lows
y1 = low - (ta.atr(30) * 2), y1B = low - ta.atr(30)
y2 = high + (ta.atr(30) * 2), y2B = high + ta.atr(30)
// Plots
windowsize = 100
offset = 0.9
sigma = 6
//plot(ta.alma(source, windowsize, offset, sigma))
windowsize2 = 310
offset2 = 0.85
sigma2 = 32
//plot(ta.alma(source, windowsize2, offset2, sigma2))
// Chart Features
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 22, 6)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(close, smrng)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
// Trend Cloud
tclength = 600
hullma = ta.wma(2*ta.wma(close, tclength/2)-ta.wma(close, tclength),
math.floor(math.sqrt(tclength)))
plot(LongTrendAverage ? hullma : na, 'Trend Cloud', linewidth=4, color=close[8] >
hullma ? color.new(#00e2ff, 65) : color.new(#fe0100, 65))
// Comulus Cloud
candle = ta.alma(source, windowsize2, offset2, sigma2)
reach = ta.alma(source, windowsize, offset, sigma)
candlep = plot(ShowComulus ? candle : na, color=color.new(color.white, 100))
reachp = plot(ShowComulus ? reach : na, color=color.new(color.white, 100))
fill(reachp, candlep, color= candle > reach ? color.new(#fe0100, 85) :
color.new(#00e2ff, 85))
// Chart Features
x1 = 22
x2 = 9
x3 = 15
x4 = 5
smoothrngX1(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrngX1 = ta.ema(avrng, wper) * m
smoothrngX1
smrngx1x = smoothrngX1(close, x1, x2)
smrngx1x2 = smoothrngX1(close, x3, x4)
rngfiltx1x1(x, r) =>
rngfiltx1x1 = x
rngfiltx1x1 := x > nz(rngfiltx1x1[1]) ? x - r < nz(rngfiltx1x1[1]) ?
nz(rngfiltx1x1[1]) : x - r : x + r > nz(rngfiltx1x1[1]) ? nz(rngfiltx1x1[1]) : x +
r
rngfiltx1x1
filtx1 = rngfiltx1x1(close, smrngx1x)
filtx12 = rngfiltx1x1(close, smrngx1x2)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
upwardx1 = 0.0
upwardx1 := filtx1 > filtx1[1] ? nz(upwardx1[1]) + 1 : filtx1 < filtx1[1] ? 0 :
nz(upwardx1[1])
downwardx1 = 0.0
downwardx1 := filtx1 < filtx1[1] ? nz(downwardx1[1]) + 1 : filtx1 > filtx1[1] ? 0 :
nz(downwardx1[1])
// Other initializations
avg_volume = ta.sma(volume, 20)
very_weak_multiplier = 0.5
weak_multiplier = 1
strong_multiplier = 1.5
// Rejection handling
var int[] demandRejections = array.new_int(history_of_demand_to_keep, 0)
var int[] supplyRejections = array.new_int(history_of_demand_to_keep, 0)
var int[] demandCreationBars = array.new_int(history_of_demand_to_keep, na)
var int[] supplyCreationBars = array.new_int(history_of_demand_to_keep, na)
f_check_demand_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(demandCreationBars, i))
if bar_index - array.get(demandCreationBars, i) > 15 and bar_index -
array.get(demandCreationBars, i) % 15 == 0
label.new(bar_index, high, "Checking demand rejection",
color=#fd0205)
dBox = array.get(current_demand_box, i)
if (na(dBox))
continue
withinBox = (high >= box.get_bottom(dBox) and high <=
box.get_top(dBox)) or (close >= box.get_bottom(dBox) and close <=
box.get_top(dBox))
bearishCandlesCount = math.sum(close < open ? 1 : 0, 15)
if withinBox and bearishCandlesCount >= 7
label.new(bar_index, low, "Bearish count > 7", color=#0395fc)
array.set(demandRejections, i, array.get(demandRejections, i) +
1)
f_check_supply_rejections() =>
for i = 0 to history_of_demand_to_keep - 1
if not na(array.get(supplyCreationBars, i))
if bar_index - array.get(supplyCreationBars, i) > 15 and bar_index -
array.get(supplyCreationBars, i) % 15 == 0
label.new(bar_index, low, "Checking supply rejection",
color=#fd0205)
sBox = array.get(current_supply_box, i)
if (na(sBox))
continue
withinBox = (low <= box.get_top(sBox) and low >=
box.get_bottom(sBox)) or (close <= box.get_top(sBox) and close >=
box.get_bottom(sBox))
bullishCandlesCount = math.sum(close > open ? 1 : 0, 15)
if withinBox and bullishCandlesCount >= 7
label.new(bar_index, high, "Bullish count > 7", color=#0395fc)
array.set(supplyRejections, i, array.get(supplyRejections, i) +
1)
f_array_add_pop(array, new_value_to_add) =>
array.unshift(array, new_value_to_add)
array.pop(array)
f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 30) // Extend only 20
bars
atr567 = ta.atr(50)
swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)
var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)
var swing_high_bns = array.new_int(5,0)
var swing_low_bns = array.new_int(5,0)
var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)
var supply_bos = array.new_box(5, na)
var demand_bos = array.new_box(5, na)
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,
current_supply_poi, 1, atr567)
else if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atr567)
f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1)
f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
// Inside the main execution, after the box is drawn, check for rejections
if not na(swing_low)
f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atr567)
f_check_demand_rejections()
if not na(swing_high)
f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)
f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,
current_supply_poi, 1, atr567)
f_check_supply_rejections()
trigger2 = bull ? 1 : 0
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
currentposition = countBull > countBear ? 'Sell' : 'Buy'
stop_y = lastTrade(atrStop)
stop = levels ? label.new(time, close, "SL " + str.tostring(stop_y, decimals),
xloc.bar_time, yloc.price, red2, label.style_label_left, color.white,
size.normal) : na
label.set_x(stop, label.get_x(stop) + math.round(ta.change(time) * lvlDistance))
label.set_y(stop, stop_y)
label.delete(stop[1])
//import protradingart/pta_plot/6 as pp
//pp.peakprofit(bull, bear)
//
///////////////////////////////////////////////////////////////////////////////////
/////////////
// Functions
// Functions
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
// Get components
// Get components
cond(_offset) =>
top = ta.highest(high, 10)
bot = ta.lowest(low, 10)
osc = ta.ema(hlc3, 5) - ta.ema(ohlc4, 20)
oscRis = osc > osc[1]
oscFal = osc < osc[1]
oscA0 = osc > 0
oscB0 = osc < 0
oscTop = oscFal and oscRis[1]
oscBot = oscRis and oscFal[1]
bullR = oscB0 and oscBot and ((osc > ta.valuewhen(oscB0 and oscBot, osc, 1)
and bot < ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearR = oscA0 and oscTop and ((osc < ta.valuewhen(oscA0 and oscTop, osc, 1)
and top > ta.valuewhen(oscA0 and oscTop, top, 1)))
bullH = oscB0 and oscBot and ((osc < ta.valuewhen(oscB0 and oscBot, osc, 1)
and bot > ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearH = oscA0 and oscTop and ((osc > ta.valuewhen(oscA0 and oscTop, osc, 1)
and top < ta.valuewhen(oscA0 and oscTop, top, 1)))
[sqzOn, sqzOff] = sqz(20, 2, 20, 2, close)
[_hist1, _line1, upper1, lower1] = qqe(6, 6, 3, close, 50, 0.001)
[_hist2, _line2, upper2, lower2] = qqe(6, 5, 1.618, close, 50, 1)
[_, _, tvr] = ta.dmi(14, 14)
[osc[_offset], oscRis[_offset], oscFal[_offset], oscA0[_offset],
oscB0[_offset], oscTop[_offset], oscBot[_offset], bullR[_offset], bearR[_offset],
bullH[_offset], bearH[_offset], sqzOn[_offset], sqzOff[_offset], _hist1[_offset],
upper1[_offset], lower1[_offset], _hist2[_offset], _line2[_offset], tvr[_offset]]
tf = indicatorTF == "Chart" ? timeframe.period : indicatorTF == "1 minute" ? "1" :
indicatorTF == "3 minutes" ? "3" : indicatorTF == "5 minutes" ? "5" : indicatorTF
== "10 minutes" ? "10" : indicatorTF == "15 minutes" ? "15" : indicatorTF == "30
minutes" ? "30" : indicatorTF == "45 minutes" ? "45" : indicatorTF == "1 hour" ?
"60" : indicatorTF == "2 hours" ? "120" : indicatorTF == "3 hours" ? "180" :
indicatorTF == "4 hours" ? "240" : indicatorTF == "12 hours" ? "720" : indicatorTF
== "1 day" ? "1D" : indicatorTF == "1 week" ? "1W" : indicatorTF == "1 month" ?
"1M" : na
[osc, oscRis, oscFal, oscA0, oscB0, oscTop, oscBot, bullR, bearR, bullH, bearH,
sqzOn, sqzOff, _hist1, upper1, lower1, _hist2, _line2, tvr] =
request.security(syminfo.tickerid, tf, cond(indicatorTF != "Chart" and
barstate.isrealtime ? 1 : 0))
//colorTVR = tvr < 15 ? #F6525F : tvr > 15 and tvr < 25 ? #B2B5BE : #66BB6A
// Plots
//plot(Presets == "Money Moves TrendVR" ? tvr : na, "", colorTVR, editable=false)
TrendText = "Trending"
if tvr < 15 and tvr < 25
TrendText := "No trend"
if is_sesd
SessionText := sesd_txt
if is_sesc
SessionText := sesc_txt
if is_sesb
SessionText := sesb_txt
if is_sesa
SessionText := NYTxt
if is_sesd and is_sesc
SessionText := "Sydney/Tokyo"
if is_sesb and is_sesc
SessionText := "Tokyo/London"
if is_sesb and is_sesa
SessionText := "London/Newyork"
if is_sesa and is_sesd
SessionText := "Newyork/Sydney"
//-----------------------------------------------------------------------------}
//Overlays color.green : color.red
//
var dashboard_loc = locationDashboard == "Top Right" ? position.top_right :
locationDashboard == "Middle Right" ? position.middle_right : locationDashboard ==
"Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ?
position.top_center : locationDashboard == "Middle Center" ? position.middle_center
: locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard
== "Top Left" ? position.top_left : locationDashboard == "Middle Left" ?
position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard ==
"Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tiny
var dashboard = showDashboard ? table.new(dashboard_loc, 3, 8, color.rgb(30,
34, 45 , 60), #3d384300, 2, color.rgb(30, 34, 45 , 60), 1) : na
dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column,
row, txt, 0, 0, signal ? #000000 : color.white, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column,
row, col)
if barstate.islast and showDashboard
// MTF Trend
dashboard_cell(0, 0 , "MTF")
dashboard_cell(0, 1 , "M1") , dashboard_cell_bg(0, 1 , TF1Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 2 , "M5") , dashboard_cell_bg(0, 2 , TF5Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 3 , "M15") , dashboard_cell_bg(0, 3 , TF15Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 4 , "M30") , dashboard_cell_bg(0, 4 , TF30Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 5 , "1H") , dashboard_cell_bg(0, 5 , TF60Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 6 , "4H") , dashboard_cell_bg(0, 6 , TF240Bull ? #0395fc :
#fd0205)
dashboard_cell(0, 7 , "D1") , dashboard_cell_bg(0, 7 , TFDBull ? #0395fc :
#fd0205)
// Middel part
dashboard_cell(1, 0 , "💎 Diamond Algo 💎")
dashboard_cell(1, 1 , "👉 Current Position ")
dashboard_cell(1, 2 , "🔎 Current Sensitivity ")
dashboard_cell(1, 3 , "🔥 Market State ")
dashboard_cell(1, 4 , "⚠️ Volatility ")
dashboard_cell(1, 5 , "🏦 Institutional Activity ")
dashboard_cell(1, 6 , "🕒 Current Session (UTC) ")
dashboard_cell(1, 7 , "🌊 Trend Pressure ")
// End part
dashboard_cell(2, 0 , "")
dashboard_cell(2, 1 , str.tostring(currentposition))
dashboard_cell(2, 2 , str.tostring(nsensitivity))
dashboard_cell(2, 3 , TrendText)
dashboard_cell(2, 4 , str.tostring(percentVol, '##.##') + '%')
dashboard_cell(2, 5 , VolitiText)
dashboard_cell(2, 6 , SessionText)
dashboard_cell(2, 7 , totalSentTxt)
// Other Features
// inputs //
//{
trailType = 'modified'
ATRPeriod = 14
ATRFactor = 6
smoothing = 8
Up = norm_c - loss
Dn = norm_c + loss
TrendUp = Up
TrendDown = Dn
Trend = 1
ex = 0.0
ex := ta.crossover(Trend, 0) ? norm_h : ta.crossunder(Trend, 0) ? norm_l : Trend ==
1 ? math.max(ex[1], norm_h) : Trend == -1 ? math.min(ex[1], norm_l) : ex[1]
//}
fib1Level = 61.8
fib2Level = 78.6
fib3Level = 88.6
if barstate.islast
float lowest_y2 = 60000
float lowest_x2 = 0
float highest_y2 = 0
float highest_x2 = 0
for i = 1 to shortPeriod by 1
if low[i] < lowest_y2
lowest_y2 := low[i]
lowest_x2 := i
lowest_x2
if high[i] > highest_y2
highest_y2 := high[i]
highest_x2 := i
highest_x2
float highest_y1 = 0
float highest_x1 = 0
//@version=5
//---------------------------------------------------------------------------------
------------------------------------}
//User Inputs
//---------------------------------------------------------------------------------
------------------------------------{
group1 = "Toggle Timeframe Weight"
//---------------------------------------------------------------------------------
------------------------------------}
//Functions
//---------------------------------------------------------------------------------
------------------------------------{
//---------------------------------------------------------------------------------
------------------------------------}
//Calculations
//---------------------------------------------------------------------------------
------------------------------------{
data = array.new_float(na)
//The max and min possible within the data are the total of all weights.
weight_sum =
(tf1Tog?tf1Multi:0) +
(tf2Tog?tf2Multi:0) +
(tf3Tog?tf3Multi:0) +
(tf4Tog?tf4Multi:0) +
(tf5Tog?tf5Multi:0) +
(tf6Tog?tf6Multi:0) +
(tf7Tog?tf7Multi:0) +
(tf8Tog?tf8Multi:0) +
(tf9Tog?tf9Multi:0) +
(tf10Tog?tf10Multi:0)
//---------------------------------------------------------------------------------
------------------------------------}
//Candle Colors
//---------------------------------------------------------------------------------
------------------------------------{
barcolor(can_color)
//---------------------------------------------------------------------------------
------------------------------------}
//Table
//---------------------------------------------------------------------------------
------------------------------------{
//Table setup
var tb = table.new(dashLoc, 10, 10
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if tf2Tog
tb.cell((vert?0:1),(vert?1:1), tf2,text_color = check_tf(tf2), text_size =
textSize, tooltip = check_tf_tt(tf2))
tb.cell((vert?1:1),(vert?1:0), bgcolor = get_col(val2), height = 1, width =
(vert?vert_width:flat_width))
if tf3Tog
tb.cell((vert?0:2),(vert?2:1), tf3,text_color = check_tf(tf3), text_size =
textSize, tooltip = check_tf_tt(tf3))
tb.cell((vert?1:2),(vert?2:0), bgcolor = get_col(val3), height = 1, width =
(vert?vert_width:flat_width))
if tf4Tog
tb.cell((vert?0:3),(vert?3:1), tf4,text_color = check_tf(tf4), text_size =
textSize, tooltip = check_tf_tt(tf4))
tb.cell((vert?1:3),(vert?3:0), bgcolor = get_col(val4), height = 1, width =
(vert?vert_width:flat_width))
if tf5Tog
tb.cell((vert?0:4),(vert?4:1), tf5,text_color = check_tf(tf5), text_size =
textSize, tooltip = check_tf_tt(tf5))
tb.cell((vert?1:4),(vert?4:0), bgcolor = get_col(val5), height = 1, width =
(vert?vert_width:flat_width))
if tf6Tog
tb.cell((vert?0:5),(vert?5:1), tf6,text_color = check_tf(tf6), text_size =
textSize, tooltip = check_tf_tt(tf6))
tb.cell((vert?1:5),(vert?5:0), bgcolor = get_col(val6), height = 1, width =
(vert?vert_width:flat_width))
if tf7Tog
tb.cell((vert?0:6),(vert?6:1), tf7,text_color = check_tf(tf7), text_size =
textSize, tooltip = check_tf_tt(tf7))
tb.cell((vert?1:6),(vert?6:0), bgcolor = get_col(val7), height = 1, width =
(vert?vert_width:flat_width))
if tf8Tog
tb.cell((vert?0:7),(vert?7:1), tf8,text_color = check_tf(tf8), text_size =
textSize, tooltip = check_tf_tt(tf8))
tb.cell((vert?1:7),(vert?7:0), bgcolor = get_col(val8), height = 1, width =
(vert?vert_width:flat_width))
if tf9Tog
tb.cell((vert?0:8),(vert?8:1), tf9,text_color = check_tf(tf9), text_size =
textSize, tooltip = check_tf_tt(tf9))
tb.cell((vert?1:8),(vert?8:0), bgcolor = get_col(val9), height = 1, width =
(vert?vert_width:flat_width))
if tf10Tog
tb.cell((vert?0:9),(vert?9:1), tf10,text_color = check_tf(tf10), text_size
= textSize, tooltip = check_tf_tt(tf10))
tb.cell((vert?1:9),(vert?9:0), bgcolor = get_col(val10), height = 1, width
= (vert?vert_width:flat_width))
//---------------------------------------------------------------------------------
------------------------------------}
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © cyatophilum
//@version=5
// Inputs {
theme = input.string('Light','Color Theme',options=['Dark','Light'])
groupEMA = 'Moving Averages'
length1 = input.int(10, 'MA 1', group = groupEMA)
length2 = input.int(20, 'MA 2', group = groupEMA)
length3 = input.int(30,'MA 3', group = groupEMA)
length4 = input.int(40,'MA 4', group = groupEMA)
length5 = input.int(50,'MA 5', group = groupEMA)
length6 = input.int(60,'MA 6', group = groupEMA)
length7 = input.int(70,'MA 7', group = groupEMA)
length8 = input.int(80,'MA 8', group = groupEMA)
length9 = input.int(90,'MA 9', group = groupEMA)
length10 = input.int(100,'MA 10', group = groupEMA)
length11 = input.int(200,'MA 11 (long term)', group = groupEMA)
groupTrend = 'Trend'
rocLength = input.int(14,'ROC length (Trend sensitivity)', group = groupTrend)
signalPercentage = input.int(5,'Reversal sensitivity (1 to 9)',minval = 1,maxval =
9, group = groupTrend)
//}
ma1 = ta.sma(close,length1)
ma2 = ta.sma(close,length2)
ma3 = ta.sma(close,length3)
ma4 = ta.sma(close,length4)
ma5 = ta.sma(close,length5)
ma6 = ta.sma(close,length6)
ma7 = ta.sma(close,length7)
ma8 = ta.sma(close,length8)
ma9 = ta.sma(close,length9)
ma10 = ta.sma(close,length10)
ma11 = ta.sma(close,length11)
roc1 = ta.roc(ma1,rocLength)
roc2 = ta.roc(ma2,rocLength)
roc3 = ta.roc(ma3,rocLength)
roc4 = ta.roc(ma4,rocLength)
roc5 = ta.roc(ma5,rocLength)
roc6 = ta.roc(ma6,rocLength)
roc7 = ta.roc(ma7,rocLength)
roc8 = ta.roc(ma8,rocLength)
roc9 = ta.roc(ma9,rocLength)
roc10 = ta.roc(ma10,rocLength)
roc11 = ta.roc(ma11,rocLength)
countBull22 =
(trendReversalBull1 ? 1 : 0) +
(trendReversalBull2 ? 1 : 0) +
(trendReversalBull3 ? 1 : 0) +
(trendReversalBull4 ? 1 : 0) +
(trendReversalBull5 ? 1 : 0) +
(trendReversalBull7 ? 1 : 0) +
(trendReversalBull8 ? 1 : 0) +
(trendReversalBull9 ? 1 : 0) +
(trendReversalBull10 ? 1 : 0)
countBear22 =
(trendReversalBear1 ? 1 : 0) +
(trendReversalBear2 ? 1 : 0) +
(trendReversalBear3 ? 1 : 0) +
(trendReversalBear4 ? 1 : 0) +
(trendReversalBear5 ? 1 : 0) +
(trendReversalBear7 ? 1 : 0) +
(trendReversalBear8 ? 1 : 0) +
(trendReversalBear9 ? 1 : 0) +
(trendReversalBear10 ? 1 : 0)
bull22 = ta.crossover(roc11,0)
bear22 = ta.crossunder(roc11,0)
reversalBull = ta.crossover(countBull,signalPercentage) and not bear
reversalBear = ta.crossover(countBear,signalPercentage) and not bull
// Render {
color colorRibbon = na
color colorRibbonA = na
color frameColor = na
if theme == 'Light'
colorRibbon := roc11 > 0 ? color.rgb(255, 255 - 255/10*countBear, 255 -
255/10*countBear) : color.rgb(255 - 255/10*countBull, 255, 255 -
255/10*countBull)
colorRibbonA := roc11 > 0 ? color.rgb(255 ,255 - 255/10*countBear, 255 -
255/10*countBear, 70) : color.rgb(255 - 255/10*countBull ,255, 255 -
255/10*countBull, 70)
frameColor := roc11 > 0 ? color.rgb(0,255,0) : color.rgb(255,0,0)
else
colorRibbon := roc11 > 0 ? color.rgb(255/10*countBear, 0, 0) :
color.rgb(0, 255/10*countBull, 0)
colorRibbonA := roc11 > 0 ? color.rgb(255/10*countBear, 0, 0, 70) :
color.rgb(0, 255/10*countBull, 0, 70)
frameColor := roc11 > 0 ? color.rgb(0, 255, 0, 50) : color.rgb(255,0,0,50)
if barstate.islast
info = table.new(position.top_right,2,2,bgcolor = colorRibbonA,frame_color =
frameColor, frame_width = 2)
table.cell(info,0,0,'Current Trend:',text_color = chart.fg_color)
table.cell(info,1,0,roc11 > 0 ? 'Bull' : 'Bear',text_color = roc11 > 0 ?
color.green : color.rgb(224, 0, 0), text_font_family =
font.family_monospace,text_size = size.large)
table.cell(info,0,1,roc11 > 0 ? 'Reversal Bear Probability:' : 'Reversal Bull
Probability:',text_color = chart.fg_color)
table.cell(info,1,1,roc11 > 0 ? str.tostring(countBear*10) + '%' :
str.tostring(countBull*10) + '%',text_color = chart.fg_color)
plot(roc1,'roc1',display = display.data_window)
plot(roc2,'roc2',display = display.data_window)
plot(roc3,'roc3',display = display.data_window)
fill(p1,p2,color=colorRibbonA)
fill(p2,p3,color=colorRibbonA)
fill(p3,p4,color=colorRibbonA)
fill(p4,p5,color=colorRibbonA)
fill(p5,p6,color=colorRibbonA)
fill(p6,p7,color=colorRibbonA)
fill(p7,p8,color=colorRibbonA)
fill(p8,p9,color=colorRibbonA)
fill(p9,p10,color=colorRibbonA)
plotshape(bull, 'Bull',shape.labelup,
location.belowbar,labelColorBull,0,'Bull',labelTextColor,size=size.small)
plotshape(bear, 'Bear',shape.labeldown,location.abovebar,labelColorBear,0,
'Bear',labelTextColor,size=size.small)
plotshape(reversalBear, 'Reversal
Bear',shape.labeldown,location.abovebar,labelColorBear,0,
'ReversalBear',labelTextColor,size=size.small)
plotshape(reversalBull, 'Reversal Bull',shape.labelup,
location.belowbar,labelColorBull,0,'Reversal Bull',labelTextColor,size=size.small)
// }
// Alerts {
alertcondition(bull, 'Bull Signal')
alertcondition(bear, 'Bear Signal')
alertcondition(reversalBull, 'Reversal Bull')
alertcondition(reversalBear, 'Reversal Bear')
//}
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © theGary
//@version=5
// inputs
sdLength = input.int(10, title = 'Price-Action Length', minval = 2, maxval =
100)
labelType = input.string('Repaint', title = 'Label Type', options = ['Repaint',
'No-Repaint'])
candleType = input.string('Fill Only', title = 'Candle Color Type', options =
['Entire Candle', 'Fill Only'])
// functions
f_getSwingValues(sdLength, offset) =>
sh = ta.pivothigh(high, sdLength, sdLength)
sl = ta.pivotlow(low, sdLength, sdLength)
hh = sh >= psh
lh = sh < psh
ll = sl <= psl
hl = sl > psl
// calculate chart tf
[sh, sl, psh, psl, csh, csl, hh, lh, ll, hl, trend, last_signal] =
request.security(syminfo.tickerid, "", f_getSwingValues(sdLength, 0))