70 lines
1.5 KiB
Plaintext
70 lines
1.5 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center Trend Magic Indicator
|
|
// ---------------------------------------------
|
|
// saherelm implementation of above indicator ...
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
|
|
//
|
|
//@version=5
|
|
indicator(title="SaherElm Trend Magic Indicator", shorttitle = "XS_TM_IND", overlay = true)
|
|
|
|
//
|
|
// START Inputs ....
|
|
//
|
|
TMPeriod = input.int(defval = 20, title = "CCI period")
|
|
TMCoeff = input.int(defval = 1, title = "ATR Multiplier")
|
|
TMAP = input.int(defval = 5, title = "ATR Period")
|
|
TMATR = ta.sma(ta.tr,TMAP)
|
|
TMSrc = input.source(defval = close, title = "Source")
|
|
//
|
|
// END Inputs ....
|
|
//
|
|
|
|
//
|
|
// START Functions ....
|
|
//
|
|
//
|
|
// END Functions ....
|
|
//
|
|
|
|
//
|
|
// START Calculations ....
|
|
//
|
|
//
|
|
TMUpT = low - TMATR * TMCoeff
|
|
TMDownT = high + TMATR * TMCoeff
|
|
|
|
//
|
|
MagicTrend = 0.0
|
|
MagicTrend := ta.cci(TMSrc, TMPeriod) >= 0 ? (TMUpT < nz(MagicTrend[1]) ? nz(MagicTrend[1]) : TMUpT) : (TMDownT > nz(MagicTrend[1]) ? nz(MagicTrend[1]) : TMDownT)
|
|
TMColor = ta.cci(TMSrc, TMPeriod) >= 0 ? color.blue : color.red
|
|
//
|
|
// END Calculations ....
|
|
//
|
|
|
|
//
|
|
// START Plots ....
|
|
//
|
|
plot(series = MagicTrend, color = TMColor, linewidth = 3, title = "Trend Magic")
|
|
//
|
|
// END Plots ....
|
|
//
|
|
|
|
//
|
|
// START Alerts ...
|
|
//
|
|
// END Alerts ...
|
|
//
|
|
|
|
//////////////////////////////////////////////////////
|
|
// TODOS:
|
|
// -------
|
|
// - []
|
|
//////////////////////////////////////////////////////
|