Better_Trin indicator

Questions about MultiCharts and user contributed studies.
stefanols
Posts: 51
Joined: 01 Jan 2014
Has thanked: 14 times
Been thanked: 2 times

Better_Trin indicator

Postby stefanols » 08 Mar 2016

Hi,

Hope someone can help me. My programming skills are under development.

I think I got most of if right but I would like to have the result
logaritmic. The compilation goes ok but then in the indicator it says
logaritm error.

Thanks in advance Stefan

Code: Select all


//Interpreted from www.emini-watch.com,
//http://emini-watch.com/free-stuff/trin-index-arms-index/

inputs:
Advn_NY( Close Data2 ), { {Adv_Issues_NY} }
Decl_NY( Close Data3 ), { Dec_Issues__NY}
Advn_Q( Close Data4 ), { {Adv_Issues_Q} }
Decl_Q( Close Data5 ), { Dec_Issues_Q }

UpVol_NY( Close Data6 ), { Adv_V_NY }
DnVol_NY( Close Data7 ), { Dec_V_NY }
UpVol_Q( Close Data8 ), { Adv_V_Q }
DnVol_Q( Close Data9 ) ; { Dec_V_Q }


variables:
IssRatio( 0 ),
VolRatio( 0 ),
Trin( 0 ),
Trinlog( 0 );

if Advn_NY <> 0 then
IssRatio = ((Advn_NY+Advn_Q) / (Decl_NY+ Decl_Q ));
if Upvol_NY <> 0 then
VolRatio = ((Upvol_NY+UpVol_Q) / (DnVol_NY+ DnVol_Q ));
Trin = ( IssRatio / VolRatio );
TrinLog = (log(Trin));

//Plot1( Trin, "Trin" ) ;

Plot1( Trinlog, "Trin" ) ;
Plot2( 0, "Zero" ) ;
Plot2( 100, "OB" ) ;
Plot2( -100, "OS" ) ;


User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Better_Trin indicator

Postby TJ » 08 Mar 2016

Hi,

Hope someone can help me. My programming skills are under development.

I think I got most of if right but I would like to have the result
logaritmic. The compilation goes ok but then in the indicator it says
logaritm error.
::
Have you ascertained that your "Trin" is a real number?

stefanols
Posts: 51
Joined: 01 Jan 2014
Has thanked: 14 times
Been thanked: 2 times

Re: Better_Trin indicator

Postby stefanols » 09 Mar 2016

Hi TJ,

Thanks for coming back to me.

Could you be so kind and guide me in the right direction
how to do this so I can study and correct.

As I saw it, it is simple deviding of numbers.

I thought it was the log function.

Thanks for your support.

Best regards

Stefan

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Better_Trin indicator

Postby TJ » 09 Mar 2016

stefanols:

After your trin calculation, add a PRINT statement.
You can see the output in your PowerLanguage Editor.
You can then do a manual calculation to verify if the trin is correct.
If Trin is 0 (zero) or a negative number, then you will not be able to do a log calculation.

Code: Select all


Trin = ( IssRatio / VolRatio );

PRINT( date, time, Trin );

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Better_Trin indicator

Postby TJ » 09 Mar 2016

I would also modify the following lines:

Code: Select all


IssRatio = (( Advn_NY data2 + Advn_Q data4 ) / (Decl_NY data3 + Decl_Q data5 ));

VolRatio = ((Upvol_NY data6 + UpVol_Q data8 ) / (DnVol_NY data7 + DnVol_Q data9 ));

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Better_Trin indicator

Postby JoshM » 09 Mar 2016

I would also modify the following lines:

Code: Select all


IssRatio = (( Advn_NY data2 + Advn_Q data4 ) / (Decl_NY data3 + Decl_Q data5 ));

VolRatio = ((Upvol_NY data6 + UpVol_Q data8 ) / (DnVol_NY data7 + DnVol_Q data9 ));
Since this is an unmotivated advice, I can only guess, but I don't think this is a good advice. If you look at the code, the inputs are already set to a certain data series. Now you hard-code these for an additional layer of complexity. And what if the inputs are changed, let's say `Advn_NY` becomes `Close data5`? Then your

Code: Select all

Advn_NY data2
expression in effect becomes

Code: Select all

(close data5) data2
I think your inputs are okay Stefanols, and I wouldn't hard-code these into the script's code unless there's a compelling reason why the script needs to become less flexible.

stefanols
Posts: 51
Joined: 01 Jan 2014
Has thanked: 14 times
Been thanked: 2 times

Re: Better_Trin indicator

Postby stefanols » 09 Mar 2016

ok thanks for your input and advice.

It shows ok if not use log function but
I probalbly need to make sure I do not devide with
0 or negative.

Best regards

Stefan


Return to “MultiCharts”