TheGrimmReaper
New member
By making some simple mathematical adjustments to the original TRIN Indicator formula you can make a more intuitive and accurate indicator. Here’s what to do to create a Better TRIN Indicator:
COMMENT: I am new to ToS, so I have no idea how to code this seemingly simple indicator. I'm hoping that after looking at this link you might also find it of interest and code it into ThinkScript for others to utilize
- Take the Log of the NYSE TRIN value
- Invert this value so negative values are positive and vice versa
- Multiply the inverted Log value by 100, and
- Repeat for the NASDAQ TRIN data and average the two values
COMMENT: I am new to ToS, so I have no idea how to code this seemingly simple indicator. I'm hoping that after looking at this link you might also find it of interest and code it into ThinkScript for others to utilize
Code:
# Eliades New TRIN (Peter Eliades)
# Nube
# cleaned up original mess 11-6-17
# changed to include both nyse and nasdaq 11-7-17
# added SP 500 11-9-17
#hint: Eliades New 10 TRIN for NYSE, S&P and NASDAQ composites
declare lower;
input Exchange = { NYSE, SP500, Default NASDAQ } ;#hint Exchange: select exchange
input LineNegative = 1.0;#hint LineNegative: input must be positive, script will invert it
assert(LineNegative > 0, "'LineNegative' must be positive - study will invert it. ");
def c = close();
def na = Double.NaN;
def dvolc = if IsNaN(c) then na else
if !IsNaN(close("$DVOLC"))
then close("$DVOLC")
else dvolc[1];
def uvolc = if IsNaN(c) then na else
if !IsNaN(close("$UVOLC"))
then close("$UVOLC")
else uvolc[1];
def advnc = if IsNaN(c) then na else
if !IsNaN(close("$ADVNC"))
then close("$ADVNC")
else advnc[1];
def decnc = if IsNaN(c) then na else
if !IsNaN(close("$DECNC"))
then close("$DECNC")
else decnc[1];
def dvolcq = if IsNaN(c) then na else
if !IsNaN(close("$DVOLC/Q"))
then close("$DVOLC/Q")
else dvolcq[1];
def uvolcq = if IsNaN(c) then na else
if !IsNaN(close("$UVOLC/Q"))
then close("$UVOLC/Q")
else uvolcq[1];
def advncq = if IsNaN(c) then na else
if !IsNaN(close("$ADVNC/Q"))
then close("$ADVNC/Q")
else advncq[1];
def decncq = if IsNaN(c) then na else
if !IsNaN(close("$DECNC/Q"))
then close("$DECNC/Q")
else decncq[1];
def dvolspc = if IsNaN(c) then na else
if !IsNaN(close("$DVOLSPC"))
then close("$DVOLSPC")
else dvolspc[1];
def uvolspc = if IsNaN(c) then na else
if !IsNaN(close("$UVOLSPC"))
then close("$UVOLSPC")
else uvolspc[1];
def advspc = if IsNaN(c) then na else
if !IsNaN(close("$ADVSPC"))
then close("$ADVSPC")
else advspc[1];
def declspc = if IsNaN(c) then na else
if !IsNaN(close("$DECLSPC"))
then close("$DECLSPC")
else declspc[1];
def dvol;
def uvol;
def advn;
def decn;
switch (Exchange) {
case NYSE:
dvol = dvolc;
uvol = uvolc;
advn = advnc;
decn = decnc;
case NASDAQ:
dvol = dvolcq;
uvol = uvolcq;
advn = advncq;
decn = decncq;
case SP500:
dvol = dvolspc;
uvol = uvolspc;
advn = advspc;
decn = declspc;
}
plot NegativeLine = -LineNegative;
NegativeLine.SetDefaultColor(Color.Gray);
NegativeLine.SetStyle(Curve.MEDIUM_DASH);
NegativeLine.HideBubble();
plot New10TRIN =-(sum(dvol,10)/sum(uvol,10)) /
(sum((advn/decn)/(uvol/dvol),10)/10);
New10TRIN.DefineColor("Up", Color.UpTick);
New10TRIN.DefineColor("Down", Color.DownTick);
New10TRIN.AssignValueColor(if New10TRIN < NegativeLine
then New10TRIN.Color("Down")
else New10TRIN.Color("Up"));
# f/
Last edited by a moderator: