//@version=5
indicator("SimpleAlgo v3", overlay=true, precision=0, explicit_plot_zorder=true,
max_labels_count=500)
//---------- EasyAlgo Community | [Link]
xHWMvMFo1W_GSJ0kqEMvA ----------//
// Get user input
emaCloud = [Link](true, "EMA Cloud?")
volCloud = [Link](false, "Volatility Cloud?")
volBands = [Link](false, "Volatility Bands?")
volSen = [Link](3, "Volatility Sensitivity (1-5 (Half Allowed))", 0.5, 5, 0.5)
signals = [Link](true, "Buy/Sell Signals?")
levels = [Link](false, "TP/SL Levels? ", inline="levels")
lvlLines = [Link](false, "Show Lines? ", inline="levels")
linesStyle = [Link]("SOLID", "", ["SOLID", "DASHED", "DOTTED"], inline="levels")
lvlDistance = [Link](1, "Distance", 1, inline="levels2")
lvlDecimals = [Link](2, " Decimals", 1, 8, inline="levels2")
suppRes = [Link](false, "Support/Resistance?")
atrLen = [Link](14, "ATR Length", 1)
atrRisk = [Link](1, "ATR/ Risk", 1)
candlesT = [Link](true, "Trending Candles")
volBandsSen = [Link](5, "Vol Bands Sensitivity (Default: 5.0)", 1)
useEma = [Link](true, "Use Exponential MA?")
barsLR = [Link](35, "S/R Looking Period", 1)
// Get Components
ema1 = [Link](ohlc4, int(5*volSen*2))
ema2 = [Link](ohlc4, int(9*volSen*2))
ema3 = [Link](ohlc4, int(13*volSen*2))
ema4 = [Link](ohlc4, int(34*volSen*2))
ema5 = [Link](ohlc4, int(50*volSen*2))
f_kc(src, len, mult) =>
float basis = useEma ? [Link](src, len) : [Link](src, len)
float span = useEma ? [Link]([Link], len) : [Link]([Link], len)
[basis + span * mult, basis - span * mult]
[upperKC1, lowerKC1] = f_kc(close, 35, 0.5236 * volBandsSen)
[upperKC2, lowerKC2] = f_kc(close, 35, 0.6854 * volBandsSen)
[upperKC3, lowerKC3] = f_kc(close, 35, 0.8472 * volBandsSen)
bull = ema3 >= ema3[1] and ema1 >= ema2 and ema1[1] < ema2[1]
bear = ema3 <= ema3[1] and ema1 <= ema2 and ema1[1] > ema2[1]
countBull = [Link](bull)
countBear = [Link](bear)
trigger = bull ? 1 : 0
atrBand = [Link](atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
barsL = barsLR
barsR = barsLR
pivotHigh = fixnan([Link](barsL, barsR)[1])
pivotLow = fixnan([Link](barsL, barsR)[1])
decimals = lvlDecimals == 1 ? "#.#" : lvlDecimals == 2 ? "#.##" : lvlDecimals == 3 ? "#.###"
: lvlDecimals == 4 ? "#.####" : lvlDecimals == 5 ? "#.#####" : lvlDecimals == 6 ?
"#.######" : lvlDecimals == 7 ? "#.#######" : "#.########"
// Colors
green = #00CC00 , green5 = volCloud ? [Link](#00CC00, 95) : na,
green12_5 = volCloud ? [Link](#00CC00, 87.5) : na, green20 = emaCloud ? #00cc0075 : na
red = #CC0000 , red5 = volCloud ? [Link](#CC0000, 95) : na,
red12_5 = volCloud ? [Link](#CC0000, 87.5) : na, red20 = emaCloud? [Link](204, 0,
0, 62) : na
orange = #FF9800 , orange50 = emaCloud ? [Link](orange, 50) : na
gray = volBands ? #787B86 : na, gray40 = volBands ? [Link](gray, 60) : na, gray5
= volBands ? [Link](gray, 95) : na, gray20 = volBands ? [Link](gray, 80) : na
// Plots
p1 = plot(ema1, "", orange50, editable=false)
p2 = plot(ema2, "", orange50, editable=false)
p3 = plot(ema3, "", orange50, editable=false)
p4 = plot(ema4, "", na, editable=false)
p5 = plot(ema5, "", na, editable=false)
fill(p4, p5, ema4 >= ema5 ? green5 : red5)
fill(p3, p4, ema3 >= ema4 ? green12_5 : red12_5)
fill(p2, p3, ema3 >= ema3[1] ? green20 : red20)
fill(p1, p2, ema1 >= ema3 ? green20 : red20)
barcolor(candlesT ? (ema3 >= ema3[1] ? green : red) : na)
b1 = plot(upperKC1, "", gray40, editable=false)
b2 = plot(upperKC2, "", gray40, editable=false)
b3 = plot(upperKC3, "", gray40, editable=false)
b4 = plot(lowerKC1, "", gray40, editable=false)
b5 = plot(lowerKC2, "", gray40, editable=false)
b6 = plot(lowerKC3, "", gray40, editable=false)
fill(b1, b2, red20)
fill(b2, b3, red)
fill(b4, b5, green20)
fill(b5, b6, green)
plot(pivotHigh, "Resistance", not suppRes or [Link](pivotHigh) ? na : red, 3, offset=-(barsR +
1), editable=false)
plot(pivotLow, "Support", not suppRes or [Link](pivotLow) ? na : green, 3, offset=-(barsR + 1),
editable=false)
y1 = low - ([Link](30) * 1.6)
y2 = high + ([Link](30) * 1.6)
buy = signals and bull ? [Link](bar_index, y1, ema4 >= ema5 ? "BUY" : "BUY",
xloc.bar_index, [Link], #00CC00, label.style_label_up, #141923, [Link]) : na
sell = signals and bear ? [Link](bar_index, y2, ema4 <= ema5 ? "SELL" : "SELL",
xloc.bar_index, [Link], #CC0000, label.style_label_down, [Link], [Link]) : na
lastTrade(src) => [Link]((ema3 >= ema3[1] and ema1 >= ema2 and ema1[1] < ema2[1])
or (ema3 <= ema3[1] and ema1 <= ema2 and ema1[1] > ema2[1]), src, 0)
entry = levels ? [Link](time, close, "ENTRY " + [Link](lastTrade(close), decimals),
xloc.bar_time, [Link], [Link], label.style_label_left, [Link], [Link]) : na
label.set_x(entry, label.get_x(entry) + [Link]([Link](time) * lvlDistance))
label.set_y(entry, lastTrade(close))
[Link](entry[1])
stop_y = lastTrade(atrStop)
stop = levels ? [Link](time, close, "SL " + [Link](stop_y, decimals), xloc.bar_time,
[Link], #CC0000, label.style_label_left, [Link], [Link]) : na
label.set_x(stop, label.get_x(stop) + [Link]([Link](time) * lvlDistance))
label.set_y(stop, stop_y)
[Link](stop[1])
tp1_y = (lastTrade(close)-lastTrade(atrStop))*1 + lastTrade(close)
tp1 = levels ? [Link](time, close, "1:1 TP " + [Link](tp1_y, decimals), xloc.bar_time,
[Link], #00CC00, label.style_label_left, [Link], [Link]) : na
label.set_x(tp1, label.get_x(tp1) + [Link]([Link](time) * lvlDistance))
label.set_y(tp1, tp1_y)
[Link](tp1[1])
tp2_y = (lastTrade(close)-lastTrade(atrStop))*2 + lastTrade(close)
tp2 = levels ? [Link](time, close, "2:1 TP " + [Link](tp2_y, decimals), xloc.bar_time,
[Link], #00CC00, label.style_label_left, [Link], [Link]) : na
label.set_x(tp2, label.get_x(tp2) + [Link]([Link](time) * lvlDistance))
label.set_y(tp2, tp2_y)
[Link](tp2[1])
tp3_y = (lastTrade(close)-lastTrade(atrStop))*3 + lastTrade(close)
tp3 = levels ? [Link](time, close, "3:1 TP " + [Link](tp3_y, decimals), xloc.bar_time,
[Link], #00CC00, label.style_label_left, [Link], [Link]) : na
label.set_x(tp3, label.get_x(tp3) + [Link]([Link](time) * lvlDistance))
label.set_y(tp3, tp3_y)
[Link](tp3[1])
style = linesStyle == "SOLID" ? line.style_solid : linesStyle == "DASHED" ? line.style_dashed :
line.style_dotted
lineEntry = levels and lvlLines ? [Link](bar_index - (trigger == 0 ? countBull : countBear),
lastTrade(close), bar_index + lvlDistance, lastTrade(close), xloc.bar_index, [Link],
[Link], style, 2) : na, [Link](lineEntry[1])
lineStop = levels and lvlLines ? [Link](bar_index - (trigger == 0 ? countBull : countBear),
stop_y, bar_index + lvlDistance, stop_y, xloc.bar_index, [Link], #CC0000, style, 2) : na,
[Link](lineStop[1])
lineTp1 = levels and lvlLines ? [Link](bar_index - (trigger == 0 ? countBull : countBear),
tp1_y, bar_index + lvlDistance, tp1_y, xloc.bar_index, [Link], #00CC00, style, 2) : na,
[Link](lineTp1[1])
lineTp2 = levels and lvlLines ? [Link](bar_index - (trigger == 0 ? countBull : countBear),
tp2_y, bar_index + lvlDistance, tp2_y, xloc.bar_index, [Link], #00CC00, style, 2) : na,
[Link](lineTp2[1])
lineTp3 = levels and lvlLines ? [Link](bar_index - (trigger == 0 ? countBull : countBear),
tp3_y, bar_index + lvlDistance, tp3_y, xloc.bar_index, [Link], #00CC00, style, 2) : na,
[Link](lineTp3[1])
// Alerts
alertcondition(bull, "Buy", "EasyAlgo Community\nBuy {{ticker}} @ {{close}}")
alertcondition(bull and ema4 >= ema5, "Firm Buy", "EasyAlgo Community\nFirm Buy {{ticker}}
@ {{close}}")
alertcondition(bear and ema4 <= ema5, "Firm Sell", "EasyAlgo Community\nFirm Sell {{ticker}}
@ {{close}}")
alertcondition(bear, "Sell", "EasyAlgo Community\nSell {{ticker}} @ {{close}}")