inserting a ratio on a chart

Questions about MultiCharts and user contributed studies.
Misha04
Posts: 12
Joined: 03 May 2010

inserting a ratio on a chart

Postby Misha04 » 08 Oct 2010

Can someone tell me how to make a ratio on a chart, for instance UUP:SPX. Thanks - Michael

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: inserting a ratio on a chart

Postby TJ » 08 Oct 2010

Misha04 wrote:Can someone tell me how to make a ratio on a chart, for instance UUP:SPX. Thanks - Michael


you have to be more specific on your request.
do you want to print a text on the chart?
do you want to plot the spread?

can you make a mock up?

Misha04
Posts: 12
Joined: 03 May 2010

Re: inserting a ratio on a chart

Postby Misha04 » 08 Oct 2010

I want to plot the ratio as a line chart. I want to have a chart of, say. UUP and in a subchart window above the instrument I want to plot the UUP:SPX ratio fpr use ad an indicator. Thanks.

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: inserting a ratio on a chart

Postby TJ » 08 Oct 2010

Misha04 wrote:I want to plot the ratio as a line chart. I want to have a chart of, say. UUP and in a subchart window above the instrument I want to plot the UUP:SPX ratio fpr use ad an indicator. Thanks.


like this?


Image


if you do a search on "spread", you will find lots of resources:

viewtopic.php?f=5&t=7845&hilit=spread
viewtopic.php?f=5&t=7844&hilit=spread
viewtopic.php?f=5&t=7843&hilit=spread

Misha04
Posts: 12
Joined: 03 May 2010

Re: inserting a ratio on a chart

Postby Misha04 » 09 Oct 2010

I don'tknow what a spread ratrio is -- what I want to do is chart one instrument, say UUP. Then I want an indicator that tells me whether UUP is underperforming or outperforming the SPX. So I want to plot a line that is a ratio of one to the other.

are you familiar with stockcharts? There I can make a price indicator that is simply the ratio, UUP:SPX, that's what I'm trying to do in MC.

thanks so much for your help wih this.....

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: inserting a ratio on a chart

Postby TJ » 09 Oct 2010

Misha04 wrote:I don'tknow what a spread ratrio is -- what I want to do is chart one instrument, say UUP. Then I want an indicator that tells me whether UUP is underperforming or outperforming the SPX. So I want to plot a line that is a ratio of one to the other.

are you familiar with stockcharts? There I can make a price indicator that is simply the ratio, UUP:SPX, that's what I'm trying to do in MC.

thanks so much for your help wih this.....


spread ratio is the name of an indicator that comes with MultiCharts.

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: inserting a ratio on a chart

Postby Dave Masalov » 11 Oct 2010

Dear Misha04,

You should plot UUP as data1, ten add SPX as data2, and insert the following inicator.
Ratio is displayed in %:

Code: Select all

vars: ratio(0);
ratio = iff( close data2 > 0, close / close data2 * 100, -1 );
plot1(ratio, "Ratio");

Maven
Posts: 7
Joined: 10 Jun 2009

Re: inserting a ratio on a chart

Postby Maven » 28 Nov 2010

Dave Masalov wrote:Dear Misha04,

You should plot UUP as data1, ten add SPX as data2, and insert the following inicator.
Ratio is displayed in %:

Code: Select all

vars: ratio(0);
ratio = iff( close data2 > 0, close / close data2 * 100, -1 );
plot1(ratio, "Ratio");



Is there a way to add a moving average to the spread ratio? I attempted to insert a EMA to it but it was asking to base the study on an instrument and no option was there to base it on the spread ratio. Please advise...thanks.

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: inserting a ratio on a chart

Postby TJ » 28 Nov 2010

Maven wrote:
Dave Masalov wrote:Dear Misha04,

You should plot UUP as data1, ten add SPX as data2, and insert the following inicator.
Ratio is displayed in %:

Code: Select all

vars: ratio(0);
ratio = iff( close data2 > 0, close / close data2 * 100, 1 );
plot1(ratio, "Ratio");



Is there a way to add a moving average to the spread ratio? I attempted to insert a EMA to it but it was asking to base the study on an instrument and no option was there to base it on the spread ratio. Please advise...thanks.


EasyLanguage is very easy to understand (and program).
Read through the codes line by line,
I think you can figure out the logic.

Go download this ebook if you want to do more experiments.
Getting Started with EasyLanguage
https://www.multicharts.com/multicharts/ ... mentation/

Code: Select all

input:
MA.length(5);

vars:
MA(0),
ratio(0);

ratio = iff( close data2 > 0, close / close data2 * 100, -1 );
MA = average(ratio, ma.length);

plot10(ratio, "Ratio");
plot20(MA, "MA");

Maven
Posts: 7
Joined: 10 Jun 2009

Re: inserting a ratio on a chart

Postby Maven » 29 Nov 2010

Thank you TJ for your post. I attempted adding the lines you posted but it would not compile correctly. Unfortunately, programming does not come easy to me as it does to you. :(


This is the Spread Ratio script that I wish to have a EMA added:


inputs: DataSeries1( Close of data1 ), DataSeries2( Close of data2 ) ;

if DataSeries2 <> 0 then
Plot1( DataSeries1 / DataSeries2, "SprdRatio" ) ;

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: inserting a ratio on a chart

Postby TJ » 29 Nov 2010

Maven wrote:Thank you TJ for your post. I attempted adding the lines you posted but it would not compile correctly. ...


What is the error message?
I have compiled it, there is no reason why you cannot.


Your code and the code from Dave Masalov gave the same effect,
but your code cannot be used in an average
because if data2 = 0, you will have a missing data slot and the average cannot compute.

Maven
Posts: 7
Joined: 10 Jun 2009

Re: inserting a ratio on a chart

Postby Maven » 30 Nov 2010

I can't figure out what I did wrong the first time, but I inserted your code a second time around and it is working just fine!

Thanks, TJ, for your assistance with this!


Return to “MultiCharts”