136 lines
3.2 KiB
Plaintext
136 lines
3.2 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center Leledc Level Indicator
|
|
// ---------------------------------------------
|
|
// saherelm implementation of above indicator ...
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
|
|
//
|
|
//@version=5
|
|
indicator(title="SaherElm Leledc Levels Indicator", shorttitle = "XS_LL_IND", overlay = true)
|
|
|
|
//
|
|
// START Inputs ....
|
|
//
|
|
exhaustionSwitch = input.bool(defval = true, title = "Show exhaustion Bar point (Arrows)")
|
|
levelSwitch = input.bool(defval = true, title = "Show exhaustion levels (Lines)")
|
|
length = input.int(defval = 40, title = "Exhaustions swing length")
|
|
bars = input.int(defval = 42, title = "Exhaustion bar count")
|
|
thicknesSwitch = input.int(defval = 7, title ="Line Thickness(Level thickness)")
|
|
//
|
|
// END Inputs ....
|
|
//
|
|
|
|
//
|
|
// START Functions ....
|
|
//
|
|
Lelec(bars, len) =>
|
|
//
|
|
result = 0
|
|
bindex = int(na)
|
|
bindex := nz(bindex[1], 0)
|
|
sindex = int(na)
|
|
sindex := nz(sindex[1], 0)
|
|
|
|
//
|
|
bindex := close > close[4] ? bindex + 1 : bindex
|
|
sindex := close < close[4] ? sindex + 1 : sindex
|
|
|
|
//
|
|
lowest = ta.lowest(low, len)
|
|
highest = ta.highest(high, len)
|
|
|
|
//
|
|
if bindex > bars and close < open and high >= highest
|
|
bindex := 0
|
|
result := -1
|
|
result
|
|
else
|
|
if sindex > bars and close > open and low <= lowest
|
|
sindex := 0
|
|
result := 1
|
|
result
|
|
//
|
|
// END Functions ....
|
|
//
|
|
|
|
//
|
|
// START Calculations ....
|
|
//
|
|
//
|
|
// Out C ...
|
|
Lelex = Lelec(bars, length)
|
|
|
|
//
|
|
// Out Bar ...
|
|
highlel = Lelex == -1 ? high : na
|
|
lowlel = Lelex == 1 ? low : na
|
|
|
|
//
|
|
// Out level ...
|
|
resistance = float(na)
|
|
support = float(na)
|
|
resistance := close < open and Lelex ? high : resistance[1]
|
|
support := close > open and Lelex ? low : support[1]
|
|
|
|
//
|
|
// Resistanse Color ...
|
|
resistanseColor = color.red
|
|
highColor = ta.change(resistance) == 0 ? resistanseColor : na
|
|
|
|
//
|
|
// Support Color ...
|
|
supportColor = color.lime
|
|
lowColor = ta.change(support) == 0 ? supportColor : na
|
|
|
|
//
|
|
// Has Signal ...
|
|
hasSignal = exhaustionSwitch
|
|
|
|
//
|
|
// Up Signals ...
|
|
upSignal = hasSignal ? lowlel : na
|
|
|
|
//
|
|
// Down Signals ...
|
|
downSignal = hasSignal ? highlel : na
|
|
//
|
|
// END Calculations ....
|
|
//
|
|
|
|
//
|
|
// START Plots ....
|
|
//
|
|
// Plot Bar ...
|
|
plotshape(hasSignal ? upSignal : na, title = "Up", color = supportColor, location = location.belowbar, style = shape.triangleup, size = size.normal)
|
|
plotshape(hasSignal ? downSignal : na, title = "Down", color = resistanseColor, location = location.abovebar, style = shape.triangledown, size = size.normal)
|
|
|
|
//
|
|
// Plot level ...
|
|
plot(levelSwitch ? resistance : na, title = "Reistance Level", style = plot.style_line, color = highColor, linewidth = thicknesSwitch)
|
|
plot(levelSwitch ? support : na, title = "Support Level", style = plot.style_line, color = lowColor, linewidth = thicknesSwitch)
|
|
|
|
//
|
|
// END Plots ....
|
|
//
|
|
|
|
//
|
|
// START Alerts ...
|
|
//
|
|
alertcondition(lowlel, "Up")
|
|
alertcondition(highlel, "Down")
|
|
//
|
|
// END Alerts ...
|
|
//
|
|
|
|
//////////////////////////////////////////////////////
|
|
// TODOS:
|
|
// -------
|
|
// - []
|
|
//////////////////////////////////////////////////////
|