//@version=5
indicator(title="I.R.M.O.C. MERGED", shorttitle="I.R.M.O.C. MERGED",
format=format.price, precision=2)
Var_Func(source, length) =>
valpha = 2 / (length + 1)
vud1 = source > source[1] ? source - source[1] : 0
vdd1 = source < source[1] ? source[1] - source : 0
vUD = math.sum(vud1, 9)
vDD = math.sum(vdd1, 9)
vCMO = nz((vUD - vDD) / (vUD + vDD))
VAR = 0.0
VAR := nz(valpha * math.abs(vCMO) * source) + (1 - valpha * math.abs(vCMO)) *
nz(VAR[1])
VAR
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
"VAR" => Var_Func(source, length)
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("VAR", title="MA Type", options=["SMA", "Bollinger
Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA", "VAR"], group="MOST Settings")
maLengthInput = input.int(5, title="MA Length", group="MOST Settings")
percent = input.float(9.0, 'STOP LOSS Percent', step=0.1, minval=0, group="MOST
Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev",
group="MOST Settings", display = display.data_window)
showDivergence = input.bool(true, title="Show Divergence", group="RSI Settings",
display = display.data_window)
showsignalsk = input(title='Show Signals?', defval=false)
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"
exMov = rsiMA
fark = exMov * percent * 0.01
longStop = exMov - fark
longStopPrev = nz(longStop[1], longStop)
longStop := exMov > longStopPrev ? math.max(longStop, longStopPrev) : longStop
shortStop = exMov + fark
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := exMov < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and exMov > shortStopPrev ? 1 : dir == 1 and exMov <
longStopPrev ? -1 : dir
MOST = dir == 1 ? longStop : shortStop
cro= ta.crossover(exMov, MOST)
cru= ta.crossunder(exMov, MOST)
direction = 0
direction := cro ? 1 : cru ? -1 : direction[1]
plot(MOST, color=color.new(color.maroon, 0), linewidth=3, title='MOST',display =
display.pane)
plotshape(cro and showsignalsk, title='BUY', text='BUY', location=location.bottom,
style=shape.labelup, size=size.tiny, color=color.new(#0F18BF, 0),
textcolor=color.new(color.white, 0),display = display.pane)
plotshape(cru and showsignalsk, title='SELL', text='SELL', location=location.top,
style=shape.labeldown, size=size.tiny, color=color.new(#0F18BF, 0),
textcolor=color.new(color.white, 0),display = display.pane)
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
plot(rsiMA, "RSI-based MA", color=color.yellow,display = display.pane)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI
Background Fill")
bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Upper Bollinger Band", color=color.green,display = display.pane)
bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Lower Bollinger Band", color=color.green,display = display.pane)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na,
title="Bollinger Bands Background Fill")
midLinePlot = plot(50, color = na, editable = false, display = display.none)
fill(rsiPlot, midLinePlot, 100, 70, top_color = color.new(color.green, 0),
bottom_color = color.new(color.green, 100), title = "Overbought Gradient Fill")
fill(rsiPlot, midLinePlot, 30, 0, top_color = color.new(color.red, 100),
bottom_color = color.new(color.red, 0), title = "Oversold Gradient Fill")
// Divergence
lookbackRight = 5
lookbackLeft = 5
rangeUpper = 60
rangeLower = 5
bearColor = color.red
bullColor = color.green
textColor = color.white
noneColor = color.new(color.white, 100)
plFound = na(ta.pivotlow(rsi, lookbackLeft, lookbackRight)) ? false : true
phFound = na(ta.pivothigh(rsi, lookbackLeft, lookbackRight)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// rsi: Higher Low
var testTable = table.new(position = position.bottom_right, columns = 1, rows = 1,
bgcolor = na, border_width = 1, force_overlay = true)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "😎😎 \nMERGED")
rsiHL = rsi[lookbackRight] > ta.valuewhen(plFound, rsi[lookbackRight], 1) and
_inRange(plFound[1])
// Price: Lower Low
priceLL = low[lookbackRight] < ta.valuewhen(plFound, low[lookbackRight], 1)
bullCondAlert = priceLL and rsiHL and plFound
bullCond = showDivergence and bullCondAlert
plot(
plFound ? rsi[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor),
display = display.pane
)
plotshape(
bullCond ? rsi[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
display = display.pane
)
//------------------------------------------------------------------------------
// Regular Bearish
// rsi: Lower High
rsiLH = rsi[lookbackRight] < ta.valuewhen(phFound, rsi[lookbackRight], 1) and
_inRange(phFound[1])
// Price: Higher High
priceHH = high[lookbackRight] > ta.valuewhen(phFound, high[lookbackRight], 1)
bearCondAlert = priceHH and rsiLH and phFound
bearCond = showDivergence and bearCondAlert
plot(
phFound ? rsi[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor)
)
plotshape(
bearCond ? rsi[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
// Inputs
src = input(close, "Source", group = "Main settings")
p = input.int(180, "Trend period", group = "Main settings", tooltip = "Changes
STRONG signals' sensitivity.", minval = 1)
atr_p = input.int(155, "ATR Period", group = "Main settings", minval = 1)
mult = input.float(2.1, "ATR Multiplier", step = 0.1, group = "Main settings",
tooltip = "Changes sensitivity: higher period = higher sensitivty.")
mode = input.string("Type A", "Signal mode", options = ["Type A", "Type B"], group
= "Mode")
use_ema_smoother = input.string("No", "Smooth source with EMA?", options = ["Yes",
"No"], group = "Source")
src_ema_period = input(3, "EMA Smoother period", group = "Source")
color_bars = input(true, "Color bars?", group = "Addons")
signals_view = input.string("All", "Signals to show", options = ["All", "Buy/Sell",
"Strong", "None"], group = "Signal's Addon")
signals_shape = input.string("Labels", "Signal's shape", options = ["Labels",
"Arrows"], group = "Signal's Addon")
buy_col = input(color.rgb(0, 255, 8), "Buy colour", group = "Signal's Addon",
inline = "BS")
sell_col = input(color.rgb(255, 0, 0), "Sell colour", group = "Signal's Addon",
inline = "BS")
// Calculations
src := use_ema_smoother == "Yes" ? ta.ema(src, src_ema_period) : src // Source;
h = ta.highest(src, p) // Highest of src p-bars back;
l = ta.lowest(src, p) // Lowest of src p-bars back.
d = h - l
ls = "" // Tracker of last signal
m = (h + l) / 2 // Initial trend line;
m := bar_index > p ? m[1] : m
atr = ta.atr(atr_p)[1] // ATR;
epsilon = mult * atr // Epsilon is a mathematical variable used in many different
theorems in order to simplify work with mathematical object. Here it used as
sensitivity measure.
change_up = (mode == "Type B" ? ta.cross(src, m + epsilon) : ta.crossover(src, m +
epsilon)) or src > m + epsilon // If price breaks trend line + epsilon (so called
higher band), then it is time to update the value of a trend line;
change_down = (mode == "Type B" ? ta.cross(src, m - epsilon) : ta.crossunder(src, m
- epsilon)) or src < m - epsilon // If price breaks trend line - epsilon (so called
higher band), then it is time to update the value of a trend line.
sb = open < l + d / 8 and open >= l
ss = open > h - d / 8 and open <= h
strong_buy = sb or sb[1] or sb[2] or sb[3] or sb[4]
strong_sell = ss or ss[1] or ss[2] or ss[3] or ss[4]
m := (change_up or change_down) and m != m[1] ? m : change_up ? m + epsilon :
change_down ? m - epsilon : nz(m[1], m) // Updating the trend line.
ls := change_up ? "B" : change_down ? "S" : ls[1] // Last signal. Helps avoid
multiple labels in a row with the same signal;
colour = ls == "B" ? buy_col : sell_col // Colour of the trend line.
buy_shape = signals_shape == "Labels" ? shape.labelup : shape.triangleup
sell_shape = signals_shape == "Labels" ? shape.labeldown : shape.triangledown
// Plottings
// Signals with label shape
plotshape(signals_shape == "Labels" and (signals_view == "All" or signals_view ==
"Buy/Sell") and change_up and ls[1] != "B" and not strong_buy, "Buy signal" ,
color = colour, style = buy_shape , location = location.belowbar, size =
size.normal, text = "BUY🚀", textcolor = color.white,display = display.pane,
force_overlay=true) // Plotting the BUY signal;
plotshape(signals_shape == "Labels" and (signals_view == "All" or signals_view ==
"Buy/Sell") and change_down and ls[1] != "S" and not strong_sell, "Sell signal" ,
color = colour, style = sell_shape, size = size.normal, text = "SELL🐻", textcolor =
color.white,display = display.pane, force_overlay=true)
// Plotting the SELL signal.
plotshape(signals_shape == "Labels" and (signals_view == "All" or signals_view ==
"Strong") and change_up and ls[1] != "B" and strong_buy, "Strong Buy signal" ,
color = colour, style = buy_shape , location = location.belowbar, size =
size.normal, text = "STRONG", textcolor = color.white,display = display.pane,
force_overlay=true) // Plotting the STRONG BUY signal;
plotshape(signals_shape == "Labels" and (signals_view == "All" or signals_view ==
"Strong") and change_down and ls[1] != "S" and strong_sell, "Strong Sell signal" ,
color = colour, style = sell_shape, size = size.normal, text = "STRONG", textcolor
= color.white,display = display.pane, force_overlay=true)
// Plotting the STRONG SELL signal.
// Signal with arrow shape
plotshape(signals_shape == "Arrows" and (signals_view == "All" or signals_view ==
"Buy/Sell") and change_up and ls[1] != "B" and not strong_buy, "Buy signal" ,
color = colour, style = buy_shape , location = location.belowbar, size =
size.tiny,display = display.pane, force_overlay=true) // Plotting the BUY signal;
plotshape(signals_shape == "Arrows" and (signals_view == "All" or signals_view ==
"Buy/Sell") and change_down and ls[1] != "S" and not strong_sell, "Sell signal" ,
color = colour, style = sell_shape, size = size.tiny,display = display.pane,
force_overlay=true) // Plotting the SELL signal.
plotshape(signals_shape == "Arrows" and (signals_view == "All" or signals_view ==
"Strong") and change_up and ls[1] != "B" and strong_buy, "Strong Buy signal" ,
color = colour, style = buy_shape , location = location.belowbar, size =
size.tiny,display = display.pane, force_overlay=true) // Plotting the STRONG BUY
signal;
plotshape(signals_shape == "Arrows" and (signals_view == "All" or signals_view ==
"Strong") and change_down and ls[1] != "S" and strong_sell, "Strong Sell signal" ,
color = colour, style = sell_shape, size = size.tiny,display = display.pane,
force_overlay=true) // Plotting the STRONG SELL
signal.
barcolor(color_bars ? colour : na) // Bar coloring
matype = input.string(title='MA Type', defval='EMA', options=['EMA', 'SMA'])
ma_len1 = input(title='Short EMA1 Length', defval=5)
ma_len2 = input(title='Long EMA1 Length', defval=7)
ma_len3 = input(title='Short EMA2 Length', defval=5)
ma_len4 = input(title='Long EMA2 Length', defval=34)
ma_len5 = input(title='Short EMA3 Length', defval=98)
ma_len6 = input(title='Long EMA3 Length', defval=45)
ma_len7 = input(title='Short EMA4 Length', defval=7)
ma_len8 = input(title='Long EMA4 Length', defval=11)
ma_len9 = input(title='Short EMA5 Length', defval=11)
ma_len10 = input(title='Long EMA5 Length', defval=15)
ma_offset = input(title='Offset', defval=0)
//res = input(title="Resolution", type=resolution, defval="240")
f_ma(malen) =>
float result = 0
if matype == 'EMA'
result := ta.ema(src, malen)
result
if matype == 'SMA'
result := ta.sma(src, malen)
result
result
htf_ma1 = f_ma(ma_len1)
htf_ma2 = f_ma(ma_len2)
htf_ma3 = f_ma(ma_len3)
htf_ma4 = f_ma(ma_len4)
htf_ma5 = f_ma(ma_len5)
htf_ma6 = f_ma(ma_len6)
htf_ma7 = f_ma(ma_len7)
htf_ma8 = f_ma(ma_len8)
htf_ma9 = f_ma(ma_len9)
htf_ma10 = f_ma(ma_len10)
//plot(out1, color=green, offset=ma_offset)
//plot(out2, color=red, offset=ma_offset)
//lengthshort = input(8, minval = 1, title = "Short EMA Length")
//lengthlong = input(200, minval = 2, title = "Long EMA Length")
//emacloudleading = input(50, minval = 0, title = "Leading Period For EMA Cloud")
//src = input(hl2, title = "Source")
showlong = input(false, title='Show Long Alerts')
showshort = input(false, title='Show Short Alerts')
showLine = input(false, title='Display EMA Line')
ema1 = input(true, title='Show EMA Cloud-1')
ema2 = input(true, title='Show EMA Cloud-2')
ema3 = input(true, title='Show EMA Cloud-3')
ema4 = input(true, title='Show EMA Cloud-4')
ema5 = input(true, title='Show EMA Cloud-5')
emacloudleading = input.int(0, minval=0, title='Leading Period For EMA Cloud')
mashort1 = htf_ma1
malong1 = htf_ma2
mashort2 = htf_ma3
malong2 = htf_ma4
mashort3 = htf_ma5
malong3 = htf_ma6
mashort4 = htf_ma7
malong4 = htf_ma8
mashort5 = htf_ma9
malong5 = htf_ma10
cloudcolour1 = mashort1 >= malong1 ? color.rgb(0, 255, 0) : color.rgb(255, 0, 0)
cloudcolour2 = mashort2 >= malong2 ? #4caf4f47 : #ff110047
cloudcolour4 = mashort4 >= malong4 ? #4caf4f52 : #f2364652
cloudcolour5 = mashort5 >= malong5 ? #33ff0026 : #ff000026
//03abc1
mashortcolor1 = mashort1 >= mashort1[1] ? color.olive : color.maroon
mashortcolor2 = mashort2 >= mashort2[1] ? color.olive : color.maroon
mashortcolor3 = mashort3 >= mashort3[1] ? color.olive : color.maroon
mashortcolor4 = mashort4 >= mashort4[1] ? color.olive : color.maroon
mashortcolor5 = mashort5 >= mashort5[1] ? color.olive : color.maroon
mashortline1 = plot(ema1 ? mashort1 : na, color=showLine ? mashortcolor1 : na,
linewidth=1, offset=emacloudleading, title='Short Leading EMA1',display =
display.pane, force_overlay=true)
mashortline2 = plot(ema2 ? mashort2 : na, color=showLine ? mashortcolor2 : na,
linewidth=1, offset=emacloudleading, title='Short Leading EMA2',display =
display.pane, force_overlay=true)
mashortline3 = plot(ema3 ? mashort3 : na, color=showLine ? mashortcolor3 : na,
linewidth=1, offset=emacloudleading, title='Short Leading EMA3',display =
display.pane, force_overlay=true)
mashortline4 = plot(ema4 ? mashort4 : na, color=showLine ? mashortcolor4 : na,
linewidth=1, offset=emacloudleading, title='Short Leading EMA4',display =
display.pane, force_overlay=true)
mashortline5 = plot(ema5 ? mashort5 : na, color=showLine ? mashortcolor5 : na,
linewidth=1, offset=emacloudleading, title='Short Leading EMA5',display =
display.pane, force_overlay=true)
malongcolor1 = malong1 >= malong1[1] ? color.green : color.red
malongcolor2 = malong2 >= malong2[1] ? color.green : color.red
malongcolor3 = malong3 >= malong3[1] ? color.green : color.red
malongcolor4 = malong4 >= malong4[1] ? color.green : color.red
malongcolor5 = malong5 >= malong5[1] ? color.green : color.red
malongline1 = plot(ema1 ? malong1 : na, color=showLine ? malongcolor1 : na,
linewidth=3, offset=emacloudleading, title='Long Leading EMA1',display =
display.pane, force_overlay=true)
malongline2 = plot(ema2 ? malong2 : na, color=showLine ? malongcolor2 : na,
linewidth=3, offset=emacloudleading, title='Long Leading EMA2',display =
display.pane, force_overlay=true)
malongline3 = plot(ema3 ? malong3 : na, color=showLine ? malongcolor3 : na,
linewidth=3, offset=emacloudleading, title='Long Leading EMA3',display =
display.pane, force_overlay=true)
malongline4 = plot(ema4 ? malong4 : na, color=showLine ? malongcolor4 : na,
linewidth=3, offset=emacloudleading, title='Long Leading EMA4',display =
display.pane, force_overlay=true)
malongline5 = plot(ema5 ? malong5 : na, color=showLine ? malongcolor5 : na,
linewidth=3, offset=emacloudleading, title='Long Leading EMA5',display =
display.pane, force_overlay=true )
fill(mashortline1, malongline1, color=cloudcolour1, title='MA Cloud1', transp=45)
fill(mashortline2, malongline2, color=cloudcolour2, title='MA Cloud2', transp=65)
fill(mashortline4, malongline4, color=cloudcolour4, title='MA Cloud4', transp=65)
fill(mashortline5, malongline5, color=cloudcolour5, title='MA Cloud5', transp=65)
leftBars = input(15, title='Left Bars ')
rightBars = input(15, title='Right Bars')
volumeThresh = input(20, title='Volume Threshold')
//
highUsePivot = fixnan(ta.pivothigh(leftBars, rightBars)[1])
lowUsePivot = fixnan(ta.pivotlow(leftBars, rightBars)[1])
r1 = plot(highUsePivot, color=ta.change(highUsePivot) ? na : #FF0000, linewidth=3,
offset=-(rightBars + 1), title='Resistance', force_overlay=true)
s1 = plot(lowUsePivot, color=ta.change(lowUsePivot) ? na : #00ff0d, linewidth=3,
offset=-(rightBars + 1), title='Support', force_overlay=true)
//Volume %
short = ta.ema(volume, 5)
long = ta.ema(volume, 10)
osc = 100 * (short - long) / long