Files

94 lines
2.1 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center STC Histogram
// ---------------------------------------------
// saherelm implementation of above oscillator ...
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
//@version=5
indicator(title="SaherElm STC Histogram", shorttitle = "XSTC_OSC", overlay = false)
//
// START Inputs ....
//
length = input(12, 'Length')
fastPeriod = input(26, 'FastLength')
slowPeriod = input(50, 'SlowLength')
//
// END Inputs ....
//
//
// START Functions ....
//
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
//
// END Functions ....
//
//
// START Calculations ....
//
maValue = AAAAA(length, fastPeriod, slowPeriod)
mColor = maValue > maValue[1] ? color.new(color.green, 20) : color.new(color.red, 20)
//
//
// END Calculations ....
//
//
// START Plots ....
//
//
plot(maValue, color = mColor, title = 'XSTC', linewidth = 2)
//
ul = plot(25, color=color.new(color.gray, 70))
ll = plot(75, color=color.new(color.gray, 70))
fill(ul, ll, color=color.new(color.gray, 96))
//
// END Plots ....
//
//
// START Alerts ...
//
//
if maValue[3] <= maValue[2] and maValue[2] > maValue[1] and maValue > 75
alert("Red", alert.freq_once_per_bar)
//
if maValue[3] >= maValue[2] and maValue[2] < maValue[1] and maValue < 25
alert("Green", alert.freq_once_per_bar)
//
// END Alerts ...
//