// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.
0
at https://mozilla.org/MPL/2.0/
// © World_of_Indicators
//Telegram:- https://t.me/world_of_indicators
//-----------------------------------------
====================================================-------------------------------
\\
// __ __ _ _ __ _____ _ _ _
// \ \ / / | | | | / _| |_ _| | (_) | |
// \ \ /\ / /__ _ __| | __| | ___ | |_ | | _ __ __| |_ ___ __ _| |_
___ _ __ ___
// \ \/ \/ / _ \| '__| |/ _` | / _ \| _| | | | '_ \ / _` | |/ __/ _` | __/
_ \| '__/ __|
// \ /\ / (_) | | | | (_| | | (_) | | _| |_| | | | (_| | | (_| (_| | ||
(_) | | \__ \
// \/ \/ \___/|_| |_|\__,_| \___/|_| |_____|_| |_|\__,_|_|\___\__,_|\__\
___/|_| |___/
//
\\
//@version=5
indicator("Super Ema Reversal by WOI", shorttitle='Super Ema Reversal by WOI',
overlay=true)
// -------------------------- user inputs ----------------------- \\
enSignals = input.bool(true, 'Enable Signals', group='Buy & Sell')
sens = input.float(5, 'Sensitivity', group='Buy & Sell')
enrev = input.bool(true, 'Enable Ichimoku Signal', group='Signals')
enrevser = input.bool(true, 'Enable Reversal Signals', group='Signals')
RSI_Period = input(21, title='Overall Reversal Sensitivitiy', group='Reversal
Signals')
SF = input(5, title='Reversal Agility', group='Reversal Signals')
KQE = input(4.238, title='Reversal Fast Senstivity', group='Reversal Signals')
ThreshHold = input(10, title='Reversal Thresh-hold', group='Reversal Signals')
ensr = input.bool(true, 'Enable Support And Resistance', group='S & R')
ensra = input.bool(true, 'Enable Support And Resistance Zones', group='S & R')
enCloud = input.bool(true, 'Enable Trend Ribbon', group='Cloud')
volBands = input.bool(true, 'Show Bands', group='Cloud')
mal = input.bool(false, 'Show Trend Moving Average Line', inline='s')
mals = input.int(50, '', inline='s')
levelsl = input.bool(false, "Sl 1", group="TP & SL")
levels1 = input.bool(false, "TP 1", group="TP & SL", inline='tp1')
r1 = input.float(0.7, '', group='TP & SL', inline='tp1')
levels2 = input.bool(false, "TP 2", group="TP & SL", inline='tp2')
r2 = input.float(1.2, '', group='TP & SL', inline='tp2')
levels3 = input.bool(false, "TP 3", group="TP & SL", inline='tp3')
r3 = input.float(1.5, '', group='TP & SL', inline='tp3')
atrRisk = input.int(defval=4, minval=1, maxval=4, title="Risk To Reward",
group="TP & SL")
// -------------------------- signal function ------------------------ \\
supertrend(_src, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _src + factor * atr
lowerBand = _src - 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]
[supertrend, direction] = supertrend(close, sens, 11)
sma9 = ta.sma(close, 14)
bull = ta.crossover(close, supertrend)
bear = ta.crossunder(close, supertrend)
y1 = low - (ta.atr(30) * 2)
y2 = high + (ta.atr(30) * 2)
// ---------------------------------- plot buy & sell signal
-------------------------- \\ based on free ai signal gold
buy = enSignals and bull ? label.new(bar_index, y1, "Woi", xloc.bar_index,
yloc.price, color.rgb(9, 255, 202), label.style_label_up, color.white, size.normal)
: na
sell = enSignals and bear ? label.new(bar_index, y2, "Woi", xloc.bar_index,
yloc.price, color.rgb(175, 0, 0), label.style_label_down, color.white, size.normal)
: na
// ---------------------------- cloud ---------------------------- \\
candle = ta.sma(close, 13)
reach = ta.sma(close, 25)
candlep = plot(enCloud ? candle : na, color=color.new(color.white, 100))
reachp = plot(enCloud ? reach : na, color=color.new(color.white, 100))
fill(reachp, candlep, color= candle > reach ? #00ae7a40 : #b8000040)
barcolor(close > supertrend ? color.rgb(9, 255, 202) : color.rgb(175, 0, 0))
// ====================--------------------- tp & sl -----------------
=================== \\ based on free algo's ai signal gold
lvlLines = (true)
linesStyle = ("DASHED")
lvlDecimals = (4)
lvlDistance = (1)
atrLen = (14)
decimals = lvlDecimals == 1 ? "#.#" : lvlDecimals == 2 ? "#.##" : lvlDecimals ==
3 ? "#.###" : lvlDecimals == 4 ? "#.####" : lvlDecimals == 5 ? "#.#####" :
lvlDecimals == 6 ? "#.######" : lvlDecimals == 7 ? "#.#######" : "#.########"
trigger = bull ? 1 : 0
trigger2 = bear ? 0 : 1
atrBand = ta.atr(atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
atrStop2 = trigger2 == -1 ? high + atrBand : low - atrBand
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
lastTrade(src) => ta.valuewhen((bull) or (bear), src, 0)
entry = levelsl or levels1 or levels2 or levels3 ? label.new(time, close, "Entry |
" + str.tostring(lastTrade(close), decimals), xloc.bar_time, yloc.price, #dbc505,
label.style_label_left, color.white, size.small) : na
label.set_x(entry, label.get_x(entry) + math.round(ta.change(time) * lvlDistance))
label.set_y(entry, lastTrade(close))
label.delete(entry[1])
stop_y = lastTrade(atrStop)
stop = levelsl ? label.new(time, close, "Stop Loss | " + str.tostring(stop_y,
decimals), xloc.bar_time, yloc.price, #bd0606, label.style_label_left,
color.new(color.white, 10), size.small) : 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])
tp1_y = (lastTrade(close)-lastTrade(atrStop))*r1 + lastTrade(close)
tp1 = levels1 ? label.new(time, close, "Take Profit 1 | " + str.tostring(tp1_y,
decimals), xloc.bar_time, yloc.price, #01d96a, label.style_label_left, color.black,
size.small) : na
label.set_x(tp1, label.get_x(tp1) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp1, tp1_y)
label.delete(tp1[1])
tp1s = ta.crossover(close, tp1_y) and not bull and close>supertrend
plotshape(tp1s, text='', style=shape.xcross, location=location.abovebar,
size=size.tiny, color=color.new(#ff000099, 68), textcolor=#2157f999)
tp1sd = ta.crossunder(close, tp1_y) and not bull and not bear and close<supertrend
plotshape(tp1sd, text='', style=shape.xcross, location=location.belowbar,
size=size.tiny, color=color.new(#2157f999, 68), textcolor=#ff000099)
tp15_y = (lastTrade(close)-lastTrade(atrStop))*r2 + lastTrade(close)
tp15 = levels2 ? label.new(time, close, "Take Profit 2 | " + str.tostring(tp15_y,
decimals), xloc.bar_time, yloc.price, #01d96a, label.style_label_left, color.black,
size.small) : na
label.set_x(tp15, label.get_x(tp15) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp15, tp15_y)
label.delete(tp15[1])
tp2s = ta.crossover(close, tp15_y) and not bull and close>supertrend
plotshape(tp2s, text='', style=shape.xcross, location=location.abovebar,
size=size.tiny, color=color.new(#ff000099, 68), textcolor=#2157f999)
tp2sd = ta.crossunder(close, tp15_y) and not bull and not bear and close<supertrend
plotshape(tp2sd, text='', style=shape.xcross, location=location.belowbar,
size=size.tiny, color=color.new(#2157f999, 68), textcolor=#ff000099)
tp2_y = (lastTrade(close)-lastTrade(atrStop))*r3 + lastTrade(close)
tp2 = levels3 ? label.new(time, close, "Take Profit 3 | " + str.tostring(tp2_y,
decimals), xloc.bar_time, yloc.price, #01d96a, label.style_label_left, color.black,
size.small) : na
label.set_x(tp2, label.get_x(tp2) + math.round(ta.change(time) * lvlDistance))
label.set_y(tp2, tp2_y)
label.delete(tp2[1])
tp3s = ta.crossover(close, tp2_y) and not bull and close>supertrend
plotshape(tp3s, text='', style=shape.xcross, location=location.abovebar,
size=size.tiny, color=color.new(#ff000099, 68), textcolor=#2157f999)
tp3sd = ta.crossunder(close, tp2_y) and not bull and not bear and close<supertrend
plotshape(tp3sd, text='', style=shape.xcross, location=location.belowbar,
size=size.tiny, color=color.new(#2157f999, 68), textcolor=#ff000099)
style = linesStyle == "SOLID" ? line.style_solid : linesStyle == "DASHED" ?
line.style_dashed : line.style_dotted
lineEntry = levelsl or levels1 or levels2 or levels3 and lvlLines ?
line.new(bar_index - (trigger == 0 ? countBull : countBear), lastTrade(close),
bar_index + lvlDistance, lastTrade(close), xloc.bar_index, extend.none, #ebeb05,
style, 2) : na, line.delete(lineEntry[1])
lineStop = levelsl and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull :
countBear), stop_y, bar_index + lvlDistance, stop_y, xloc.bar_index, extend.none,
color.new(color.rgb(196, 0, 0), 0), style, 2) : na, line.delete(lineStop[1])
lineTp1 = levels1 and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull :
countBear), tp1_y, bar_index + lvlDistance, tp1_y, xloc.bar_index, extend.none,
#00fc93, style, 2) : na, line.delete(lineTp1[1])
lineTp15 = levels2 and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull :
countBear), tp15_y, bar_index + lvlDistance, tp15_y, xloc.bar_index, extend.none,
#00fc93, style, 2) : na, line.delete(lineTp15[1])
lineTp2 = levels3 and lvlLines ? line.new(bar_index - (trigger == 0 ? countBull :
countBear), tp2_y, bar_index + lvlDistance, tp2_y, xloc.bar_index, extend.none,
#00fc93, style, 2) : na, line.delete(lineTp2[1])
// ----------------------------------------- bands
----------------------------------- \\
useEma = true
int volBandsSen = 5
gray = volBands ? #787B86 : na, gray40 = volBands ? color.new(gray, 60) : na,
gray5 = volBands ? color.new(gray, 95) : na, gray20 = volBands ? color.new(gray,
80) : na
//
f_kc(src, len, mult) =>
float basis = useEma ? ta.ema(src, len) : ta.sma(src, len)
float span = useEma ? ta.ema(ta.tr, len) : ta.sma(ta.tr, len)
[basis + span * mult, basis - span * mult]
[upperKC1, lowerKC1] = f_kc(close, 35, 4.5 )
[upperKC2, lowerKC2] = f_kc(close, 35, 6.4 )
[upperKC3, lowerKC3] = f_kc(close, 35, 8.3 )
// ---------------------------- moving average line
------------------------------------- \\
short = ta.ema(close, 15)
intm = ta.ema(close, 100)
long = ta.ema(close, mals)
// set bull
mal_is_bull = (short > intm ? #04a87c40 : #96030340)
// plot it
plot(mal ? long : na, color = mal_is_bull, linewidth=4)
//--------------------------- reversal signals --------------------------- \\
s1_vis = true
i1_s1 = 'Conversion Line'
f_s1 = 'crossover'
i2_s1 = 'Base Line'
s2_vis = true
i1_s2 = 'Lead 1'
f_s2 = 'crossover'
i2_s2 = 'Lead 2'
s3_vis = true
s4_vis = true
conversionPeriods = 9
basePeriods = 26
laggingSpan2Periods = 52
displacement = 26
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
lead1 = leadLine1[displacement - 1]
lead2 = leadLine2[displacement - 1]
bool breakup = na
bool breakdn = na
crossup = ta.crossover(close, lead2) and close>ta.ema(close,5)
green_candle = close > open
if lead2 > lead1 and green_candle
breakup := crossup
breakup
plotshape(enrev and breakup and s3_vis ? high : na, 'Ichimoku (Break Up)',
shape.diamond, location.belowbar, #eeff0061, size=size.small)
//bgcolor(enrev and breakup and s3_vis ? color.new(#00DBFF, 95) : na, title='Break
Up Background', transp=90)
crossdn = ta.crossunder(close, lead2)
red_candle = close < open
if lead2 < lead1 and red_candle
breakdn := crossdn
breakdn
plotshape(enrev and breakdn and s4_vis ? low : na, 'Ichimoku (Break Down)',
shape.diamond, location.abovebar, #f64f0152, size=size.small)
// ------------------------------ support and resistance --------------------------
\\
left = 20
right = 15
quick_right = 5// Used to try and detect a more recent significant swing.
pivot_high = ta.pivothigh(high, left, right)
pivot_lows = ta.pivotlow(low, left, right)
quick_pivot_high = ta.pivothigh(high, left, quick_right)
quick_pivot_lows = ta.pivotlow(low, left, quick_right)
level1 = ta.valuewhen(quick_pivot_high, high[quick_right], 0)
level2 = ta.valuewhen(quick_pivot_lows, low[quick_right], 0)
level3 = ta.valuewhen(pivot_high, high[right], 0)
level4 = ta.valuewhen(pivot_lows, low[right], 0)
level5 = ta.valuewhen(pivot_high, high[right], 1)
level6 = ta.valuewhen(pivot_lows, low[right], 1)
level7 = ta.valuewhen(pivot_high, high[right], 2)
level8 = ta.valuewhen(pivot_lows, low[right], 2)
level1_col = close >= level1 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level2_col = close >= level2 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level3_col = close >= level3 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level4_col = close >= level4 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level5_col = close >= level5 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level6_col = close >= level6 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level7_col = close >= level7 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
level8_col = close >= level8 ? color.rgb(3, 228, 123) : color.rgb(196, 0, 0)
plot(ensr ? level1 :na, style=plot.style_line, color=level1_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr ?level2:na, style=plot.style_line, color=level2_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level3:na, style=plot.style_line, color=level3_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level4:na, style=plot.style_line, color=level4_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level5:na, style=plot.style_line, color=level5_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level6:na, style=plot.style_line, color=level6_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level7:na, style=plot.style_line, color=level7_col, show_last=1,
linewidth=2, trackprice=true)
plot(ensr?level8:na, style=plot.style_line, color=level8_col, show_last=1,
linewidth=2, trackprice=true)
ig1 = ensra?line.new(bar_index, level1, bar_index + 1, level1, xloc.bar_index,
extend.both, color.new(level1_col, 85), line.style_solid, 13):na
ig2 = ensra?line.new(bar_index, level2, bar_index + 1, level2, xloc.bar_index,
extend.both, color.new(level2_col, 85), line.style_solid, 13):na
ig3 = ensra?line.new(bar_index, level3, bar_index + 1, level3, xloc.bar_index,
extend.both, color.new(level3_col, 85), line.style_solid, 13):na
ig4 = ensra?line.new(bar_index, level4, bar_index + 1, level4, xloc.bar_index,
extend.both, color.new(level4_col, 85), line.style_solid, 13):na
ig5 = ensra?line.new(bar_index, level5, bar_index + 1, level5, xloc.bar_index,
extend.both, color.new(level5_col, 85), line.style_solid, 13):na
ig6 = ensra?line.new(bar_index, level6, bar_index + 1, level6, xloc.bar_index,
extend.both, color.new(level6_col, 85), line.style_solid, 13):na
ig7 = ensra?line.new(bar_index, level7, bar_index + 1, level7, xloc.bar_index,
extend.both, color.new(level7_col, 85), line.style_solid, 13):na
ig8 = ensra?line.new(bar_index, level8, bar_index + 1, level8, xloc.bar_index,
extend.both, color.new(level8_col, 85), line.style_solid, 13):na
//--------------------------- reversal signals -------------------------------- \\
src = close
Wilders_Period = RSI_Period * 2 - 1
Rsi = ta.rsi(src, RSI_Period)
RsiMa = ta.ema(Rsi, SF)
AtrRsi = math.abs(RsiMa[1] - RsiMa)
MaAtrRsi = ta.ema(AtrRsi, Wilders_Period)
dar = ta.ema(MaAtrRsi, Wilders_Period) * KQE
longband = 0.0
shortband = 0.0
trend = 0
DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ?
math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ?
math.min(shortband[1], newshortband) : newshortband
cross_1 = ta.cross(longband[1], RSIndex)
trend := ta.cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband
Exlong = 0
Exlong := nz(Exlong[1])
Exshort = 0
Exshort := nz(Exshort[1])
Exlong := FastAtrRsiTL < RSIndex ? Exlong + 1 : 0
Exshort := FastAtrRsiTL > RSIndex ? Exshort + 1 : 0
//Conditions
qqeLong = Exlong == 1 ? FastAtrRsiTL[1] - 50 : na
qqeShort = Exshort == 1 ? FastAtrRsiTL[1] - 50 : na
// Plotting
plotshape(qqeLong and enrevser and barstate.isconfirmed, title='Reversal',
text='rev\nup', textcolor=color.new(color.white, 99), style=shape.triangleup,
location=location.belowbar, color=color.new(color.rgb(3, 228, 123), 35),
size=size.tiny)
plotshape(qqeShort and enrevser and barstate.isconfirmed, title='Reversal',
text='rev\ndown', textcolor=color.new(color.white, 99), style=shape.triangledown,
location=location.abovebar, color=color.new(color.rgb(196, 0, 0), 35),
size=size.tiny)