Here is the code for the famous Traders Dynamic Index aka the “TDI”.
//parameters
// lengthRSI = 13
// lengthband = 34
// lengthrsipl = 2
// lengthtradesl = 7
r = rsi[lengthrsi](close)
ma = average[lengthband](r)
offs = (1.6185 * std[lengthband](r))
up = ma+offs
dn = ma-offs
mid = (up+dn)/2
mab = average[lengthrsipl](r)
mbb = average[lengthtradesl](r)
lineup = 68
linemid = 50
linedown = 32
RETURN lineup as "line up", linemid as "line mid", linedown as "line down", up coloured(0,238,238) as "up", dn coloured(0,238,238) as "dn", mid coloured(255,165,0) as "mid", mab coloured(0,255,0), mbb coloured(255,0,0)